diff options
Diffstat (limited to 'kicker/kicker/core')
-rw-r--r-- | kicker/kicker/core/CMakeLists.txt | 2 | ||||
-rw-r--r-- | kicker/kicker/core/container_base.cpp | 4 | ||||
-rw-r--r-- | kicker/kicker/core/container_extension.cpp | 139 | ||||
-rw-r--r-- | kicker/kicker/core/container_extension.h | 10 | ||||
-rw-r--r-- | kicker/kicker/core/kicker.cpp | 37 | ||||
-rw-r--r-- | kicker/kicker/core/kicker.h | 3 | ||||
-rw-r--r-- | kicker/kicker/core/usersizesel.cpp | 235 | ||||
-rw-r--r-- | kicker/kicker/core/usersizesel.h | 64 |
8 files changed, 479 insertions, 15 deletions
diff --git a/kicker/kicker/core/CMakeLists.txt b/kicker/kicker/core/CMakeLists.txt index a18de2393..4db8c69d9 100644 --- a/kicker/kicker/core/CMakeLists.txt +++ b/kicker/kicker/core/CMakeLists.txt @@ -38,7 +38,7 @@ set( target kicker_core ) set( ${target}_SRCS extensionSettings.kcfgc main.cpp kicker.cpp kicker.skel - userrectsel.cpp containerarea.cpp kmenubase.ui + userrectsel.cpp usersizesel.cpp containerarea.cpp kmenubase.ui applethandle.cpp container_base.cpp container_button.cpp container_applet.cpp container_extension.cpp extensionmanager.cpp menumanager.cpp pluginmanager.cpp showdesktop.cpp diff --git a/kicker/kicker/core/container_base.cpp b/kicker/kicker/core/container_base.cpp index 183ceb0f2..c42387173 100644 --- a/kicker/kicker/core/container_base.cpp +++ b/kicker/kicker/core/container_base.cpp @@ -46,7 +46,9 @@ BaseContainer::BaseContainer( TQPopupMenu* appletOpMenu, TQWidget* parent, const , m_immutable(false) , _opMnu(0) , _appletOpMnu(appletOpMenu) -{} +{ + setCursor(tqarrowCursor); +} BaseContainer::~BaseContainer() { diff --git a/kicker/kicker/core/container_extension.cpp b/kicker/kicker/core/container_extension.cpp index 87ed34267..80ceb6e13 100644 --- a/kicker/kicker/core/container_extension.cpp +++ b/kicker/kicker/core/container_extension.cpp @@ -61,6 +61,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include "kickertip.h" #include "pluginmanager.h" #include "userrectsel.h" +#include "usersizesel.h" #include "container_extension.h" @@ -178,7 +179,7 @@ void ExtensionContainer::init() { _userHidden = static_cast<UserHidden>(tmp); } - + if (m_extension) { // if we have an extension, we need to grab the extension-specific @@ -218,6 +219,8 @@ void ExtensionContainer::init() m_settings.setIExist(true); m_settings.writeConfig(); } + + setMouseTracking(true); } ExtensionContainer::~ExtensionContainer() @@ -2028,6 +2031,66 @@ TQRect ExtensionContainer::initialGeometry(KPanelExtension::Position p, return TQRect(point, size); } +bool ExtensionContainer::inResizeArea(TQPoint mousePos) const +{ + if (KickerSettings::useResizeHandle() && + !KickerSettings::locked() && + !Kicker::the()->isImmutable() && + !m_settings.config()->isImmutable() && + !ExtensionManager::the()->isMenuBar(this)) + { + KPanelExtension::Position pos = position(); + if (pos == KPanelExtension::Left) + { + if (mousePos.x() < (width() - PANEL_RESIZE_HANDLE_WIDTH)) + { + return false; + } + else + { + return true; + } + } + else if (pos == KPanelExtension::Right) + { + if (mousePos.x() <= PANEL_RESIZE_HANDLE_WIDTH) + { + return true; + } + else + { + return false; + } + } + else if (pos == KPanelExtension::Top) + { + if (mousePos.y() < (height() - PANEL_RESIZE_HANDLE_WIDTH)) + { + return false; + } + else + { + return true; + } + } + else + { + if (mousePos.y() <= PANEL_RESIZE_HANDLE_WIDTH) + { + return true; + } + else + { + return false; + } + } + } + else + { + return false; + } +} + bool ExtensionContainer::eventFilter( TQObject*, TQEvent * e) { if (autoHidden()) @@ -2066,8 +2129,27 @@ bool ExtensionContainer::eventFilter( TQObject*, TQEvent * e) TQMouseEvent* me = TQT_TQMOUSEEVENT(e); if ( me->button() == Qt::LeftButton ) { - _last_lmb_press = me->globalPos(); - _is_lmb_down = true; + if (inResizeArea(me->pos())) + { + _last_lmb_press = me->globalPos(); + _is_lmb_down = true; + + KPanelExtension::Position pos = position(); + TQRect newRect = UserSizeSel::select(geometry(), position(), m_highlightColor); + if ((pos == KPanelExtension::Left) || (pos == KPanelExtension::Right)) + { + setSize(KPanelExtension::SizeCustom, newRect.width()-((KickerSettings::useResizeHandle())?(PANEL_RESIZE_HANDLE_WIDTH + PANEL_BOTTOM_SPACING_W_RESIZE_HANDLE):0)); + } + if ((pos == KPanelExtension::Top) || (pos == KPanelExtension::Bottom)) + { + setSize(KPanelExtension::SizeCustom, newRect.height()-((KickerSettings::useResizeHandle())?(PANEL_RESIZE_HANDLE_WIDTH + PANEL_BOTTOM_SPACING_W_RESIZE_HANDLE):0)); + } + } + else + { + _last_lmb_press = me->globalPos(); + _is_lmb_down = true; + } } else if (me->button() == Qt::RightButton) { @@ -2089,7 +2171,56 @@ bool ExtensionContainer::eventFilter( TQObject*, TQEvent * e) case TQEvent::MouseMove: { - TQMouseEvent* me = (TQMouseEvent*) e; + TQMouseEvent* me = TQT_TQMOUSEEVENT(e); + if (KickerSettings::useResizeHandle()) + { + KPanelExtension::Position pos = position(); + if (pos == KPanelExtension::Left) + { + if (inResizeArea(me->pos())) + { + setCursor(sizeHorCursor); + } + else + { + setCursor(tqarrowCursor); + } + } + else if (pos == KPanelExtension::Right) + { + if (inResizeArea(me->pos())) + { + setCursor(sizeHorCursor); + } + else + { + setCursor(tqarrowCursor); + } + } + else if (pos == KPanelExtension::Top) + { + if (inResizeArea(me->pos())) + { + setCursor(tqsizeVerCursor); + } + else + { + setCursor(tqarrowCursor); + } + } + else + { + if (inResizeArea(me->pos())) + { + setCursor(tqsizeVerCursor); + } + else + { + setCursor(tqarrowCursor); + } + } + } + if (_is_lmb_down && ((me->state() & Qt::LeftButton) == Qt::LeftButton) && !Kicker::the()->isImmutable() && diff --git a/kicker/kicker/core/container_extension.h b/kicker/kicker/core/container_extension.h index 724ba0a10..81752bffa 100644 --- a/kicker/kicker/core/container_extension.h +++ b/kicker/kicker/core/container_extension.h @@ -100,6 +100,8 @@ public: void unhideIfHidden(int showForHowManyMS = 0); bool reserveStrut() const; + bool inResizeArea(TQPoint mousePos) const; + KPanelExtension::Alignment alignment() const; void setAlignment(KPanelExtension::Alignment a) { arrange( position(), a, xineramaScreen() ); } @@ -172,17 +174,17 @@ private: bool _autoHidden; UserHidden _userHidden; bool _block_user_input; - TQPoint _last_lmb_press; + TQPoint _last_lmb_press; bool _is_lmb_down; bool _in_autohide; // Misc objects - TQTimer *_autohideTimer; - TQTimer *_updateLayoutTimer; + TQTimer *_autohideTimer; + TQTimer *_updateLayoutTimer; NETExtendedStrut _strut; PopupWidgetFilter *_popupWidgetFilter; - TQString _id; + TQString _id; PanelExtensionOpMenu *_opMnu; AppletInfo _info; KPanelExtension::Type _type; diff --git a/kicker/kicker/core/kicker.cpp b/kicker/kicker/core/kicker.cpp index 4c433aa8e..7410d4877 100644 --- a/kicker/kicker/core/kicker.cpp +++ b/kicker/kicker/core/kicker.cpp @@ -320,7 +320,7 @@ void Kicker::setInsertionPoint(const TQPoint &p) } -void Kicker::showConfig(const TQString& configPath, int page) +void Kicker::showConfig(const TQString& configPath, const TQString& configFile, int page) { if (!m_configDialog) { @@ -328,9 +328,27 @@ void Kicker::showConfig(const TQString& configPath, int page) TQStringList modules = configModules(false); TQStringList::ConstIterator end(modules.end()); + int moduleNumber = 0; for (TQStringList::ConstIterator it = modules.begin(); it != end; ++it) { - m_configDialog->addModule(*it); + if (configFile == "") + { + m_configDialog->addModule(*it); + } + else + { + if (moduleNumber == page) + { + TQStringList argList; + argList << configFile; + m_configDialog->addModule(*it, true, argList); + } + else + { + m_configDialog->addModule(*it); + } + } + moduleNumber++; } connect(m_configDialog, TQT_SIGNAL(finished()), TQT_SLOT(configDialogFinished())); @@ -349,13 +367,24 @@ void Kicker::showConfig(const TQString& configPath, int page) m_configDialog->raise(); if (page > -1) { - m_configDialog->showPage(page); + if (configFile == "") + { + m_configDialog->showPage(0); + } + else { + m_configDialog->showPage(page); + } } } void Kicker::showTaskBarConfig() { - showConfig(TQString(), 4); + showConfig(TQString(), TQString(), 4); +} + +void Kicker::showTaskBarConfig(const TQString& configFile) +{ + showConfig(TQString(), configFile, 4); } void Kicker::configureMenubar() diff --git a/kicker/kicker/core/kicker.h b/kicker/kicker/core/kicker.h index bc00e1915..0416bc5ce 100644 --- a/kicker/kicker/core/kicker.h +++ b/kicker/kicker/core/kicker.h @@ -56,8 +56,9 @@ k_dcop: void showKMenu(); void toggleShowDesktop(); bool desktopShowing(); - void showConfig(const TQString& config, int page = -1); + void showConfig(const TQString& config, const TQString& configFile = TQString::null, int page = -1); void showTaskBarConfig(); + void showTaskBarConfig(const TQString& configFile); void configureMenubar(); // return the region on the desktop, which is not covered by panels // and therefore allowed to be used by icons placed on the desktop diff --git a/kicker/kicker/core/usersizesel.cpp b/kicker/kicker/core/usersizesel.cpp new file mode 100644 index 000000000..107a2527a --- /dev/null +++ b/kicker/kicker/core/usersizesel.cpp @@ -0,0 +1,235 @@ +/***************************************************************** + +Copyright (c) 1996-2000 the kicker authors. See file AUTHORS. +Copyright (c) 2012 Timothy Pearson <kb9vqf@pearsoncomputing.net> + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +******************************************************************/ + +#include <tqapplication.h> +#include <tqpainter.h> +#include <tqcursor.h> + +#include "usersizesel.h" +#include "usersizesel.moc" + +#define PANEL_MINIMUM_HEIGHT 16 + +UserSizeSel::UserSizeSel(const TQRect& rect, const KPanelExtension::Position pos, const TQColor& color) + : TQWidget(0, 0, (WFlags)(WStyle_Customize | WX11BypassWM)), + _orig_size(0), + _rect(rect), + _orig_rect(rect), + _pos(pos), + _frame1_shown(false), + _frame2_shown(false) +{ + if ((pos == KPanelExtension::Left) || (pos == KPanelExtension::Right)) + { + setCursor(sizeHorCursor); + } + if ((pos == KPanelExtension::Top) || (pos == KPanelExtension::Bottom)) + { + setCursor(tqsizeVerCursor); + } + + setGeometry(-10, -10, 2, 2); + _color = color; + for (int i = 0; i < 8; i++) + { + _frame[i] = 0; + } +} + +UserSizeSel::~UserSizeSel() +{ + for (int i = 0; i < 8; i++) + { + delete _frame[i]; + } + _frame1_shown = false; + _frame2_shown = false; +} + +void UserSizeSel::mouseReleaseEvent(TQMouseEvent * e) +{ + if (e->button() == Qt::LeftButton) + { + tqApp->exit_loop(); + } +} + +void UserSizeSel::mouseMoveEvent(TQMouseEvent * e) +{ + int newSize = _orig_size; + TQPoint p(e->globalPos() - _orig_mouse_pos); + + if (_pos == KPanelExtension::Left) + { + newSize = _orig_size + p.x(); + } + if (_pos == KPanelExtension::Right) + { + newSize = _orig_size + ((-1)*p.x()); + } + if (_pos == KPanelExtension::Top) + { + newSize = _orig_size + p.y(); + } + if (_pos == KPanelExtension::Bottom) + { + newSize = _orig_size + ((-1)*p.y()); + } +// int screen = xineramaScreen(); +// if (screen < 0) +// { +// screen = kapp->desktop()->screenNumber(this); +// } +// TQRect desktopGeom = TQApplication::desktop()->screenGeometry(screen); + if (newSize < PANEL_MINIMUM_HEIGHT) + { + newSize = PANEL_MINIMUM_HEIGHT; + } + int maxSize = 256; +// if ((_pos == KPanelExtension::Left) || (_pos == KPanelExtension::Right)) +// { +// maxSize = desktopGeom.width()/2; +// } +// if ((_pos == KPanelExtension::Top) || (_pos == KPanelExtension::Bottom)) +// { +// maxSize = desktopGeom.height()/2; +// } + if (newSize > maxSize) + { + newSize = maxSize; + } + + if (_pos == KPanelExtension::Left) + { + _rect.setWidth(newSize); + } + if (_pos == KPanelExtension::Right) + { + _rect.setX(_orig_rect.x()-(newSize-_orig_size)); + _rect.setWidth(newSize); + } + if (_pos == KPanelExtension::Top) + { + _rect.setHeight(newSize); + } + if (_pos == KPanelExtension::Bottom) + { + _rect.setY(_orig_rect.y()-(newSize-_orig_size)); + _rect.setHeight(newSize); + } + + // Compress paint events to increase responsiveness + if (TQCursor::pos() == e->globalPos()) + { + paintCurrent(); + } +} + +void UserSizeSel::paintCurrent() +{ + int i; + int x, y, w, h; + + if (!_frame[0]) + { + for (i = 0; i < 4; i++) + { + _frame[i] = new TQWidget(0, 0, (WFlags)(WStyle_Customize | WStyle_NoBorder | WX11BypassWM)); + _frame[i]->setPaletteBackgroundColor(Qt::black); + } + for (i = 4; i < 8; i++) + { + _frame[i] = new TQWidget(0, 0, (WFlags)(WStyle_Customize | WStyle_NoBorder | WX11BypassWM)); + _frame[i]->setPaletteBackgroundColor(_color); + } + } + + x = _rect.x(); + y = _rect.y(); + w = _rect.width(); + h = _rect.height(); + + if (w > 0 && h > 0) + { + _frame[0]->setGeometry(x, y, w, 4); + _frame[1]->setGeometry(x, y, 4, h); + _frame[2]->setGeometry(x + w - 4, y, 4, h); + _frame[3]->setGeometry(x, y + h - 4, w, 4); + + if (!_frame1_shown) + { + for (i = 0; i < 4; i++) + { + _frame[i]->show(); + } + _frame1_shown = true; + } + } + + x += 1; + y += 1; + w -= 2; + h -= 2; + + if (w > 0 && h > 0) + { + _frame[4]->setGeometry(x, y, w, 2); + _frame[5]->setGeometry(x, y, 2, h); + _frame[6]->setGeometry(x + w - 2, y, 2, h); + _frame[7]->setGeometry(x, y + h - 2, w, 2); + + if (!_frame2_shown) + { + for (i = 4; i < 8; i++) + { + _frame[i]->show(); + } + _frame2_shown = true; + } + } + +} + +TQRect UserSizeSel::select(const TQRect& rect, const KPanelExtension::Position pos, const TQColor& color) +{ + UserSizeSel sel(rect, pos, color); + sel._orig_mouse_pos = TQCursor::pos(); + if ((pos == KPanelExtension::Left) || (pos == KPanelExtension::Right)) + { + sel._orig_size = rect.width(); + } + if ((pos == KPanelExtension::Top) || (pos == KPanelExtension::Bottom)) + { + sel._orig_size = rect.height(); + } + sel.show(); + sel.grabMouse(); + sel.paintCurrent(); + tqApp->enter_loop(); + sel.paintCurrent(); + sel.releaseMouse(); + tqApp->syncX(); + return sel._rect; +} + diff --git a/kicker/kicker/core/usersizesel.h b/kicker/kicker/core/usersizesel.h new file mode 100644 index 000000000..64c8950bd --- /dev/null +++ b/kicker/kicker/core/usersizesel.h @@ -0,0 +1,64 @@ +/***************************************************************** + +Copyright (c) 1996-2000 the kicker authors. See file AUTHORS. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +******************************************************************/ + +#ifndef __usersizesel_h__ +#define __usersizesel_h__ + +#include <tqwidget.h> +#include <tqvaluevector.h> +#include <tqcolor.h> + +#include <kpanelextension.h> + +class ShutUpCompiler; + +class UserSizeSel : public TQWidget +{ + Q_OBJECT + + public: + static TQRect select(const TQRect& rect, const KPanelExtension::Position pos, const TQColor& color); + + protected: + void mouseReleaseEvent(TQMouseEvent *); + void mouseMoveEvent(TQMouseEvent *); + + private: + UserSizeSel(const TQRect& rect, const KPanelExtension::Position pos, const TQColor& color); + ~UserSizeSel(); + void paintCurrent(); + + TQPoint _orig_mouse_pos; + int _orig_size; + TQRect _rect; + TQRect _orig_rect; + KPanelExtension::Position _pos; + TQWidget *_frame[8]; + TQColor _color; + bool _frame1_shown; + bool _frame2_shown; + + friend class ShutUpCompiler; +}; + +#endif |