[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-devel
Subject:    [PATCH] kicker resizing
From:       "Gerold J. Wucherpfennig" <gjwucherpfennig () gmx ! net>
Date:       2002-05-01 22:31:46
[Download RAW message or body]

Hi, this patch prevents users from accidentially resizing kicker when the
/size/ "Custom" is selected. I added a lock mechanism, a check item called
"Resizable". One or two months ago, before KDE3.0 was released
(during the i18n freeze period), I posted an earlier patch and someone said
it looked ok to him.

Please review and apply if it looks ok.

I'm not subscribed to this list (not any more),
so it would be nice if you CC me.






[" " (text/x-diff)]

diff -urN kicker/core/panel.cpp kicker_/core/panel.cpp
--- kicker/core/panel.cpp	Thu Mar 14 23:01:34 2002
+++ kicker_/core/panel.cpp	Thu May  2 00:03:35 2002
@@ -65,6 +65,7 @@
     _frame->setFrameStyle(QFrame::StyledPanel  | QFrame::Raised);
     _frame->setLineWidth(2);
     _frame->enableResizeHandle( false );
+    _resizable=false;
     _frame->setResizePosition( FittsLawFrame::Top );
 
     connect( _frame, SIGNAL( resizeRequest( int, int ) ),
@@ -109,6 +110,7 @@
     config->setGroup("General");
 
     _panelsize = config->readNumEntry( "Size", sizeValue( Normal ) );
+    _resizable = config->readBoolEntry( "Resizable", false );
 
     // backward compatibility
     if ( _panelsize == 0 ) _panelsize = sizeValue( Tiny );
@@ -118,7 +120,7 @@
 
     _panelsize = QMIN( QMAX( _panelsize, MIN_PANEL_SIZE ), MAX_PANEL_SIZE );
 
-    _frame->enableResizeHandle( size() == ::Custom && !Kicker::kicker()->isImmutable() );
+    _frame->enableResizeHandle( _resizable && !Kicker::kicker()->isImmutable() );
 
     PanelContainer::readConfig( config );
 }
@@ -131,6 +133,7 @@
     config->setGroup("General");
 
     config->writeEntry( "Size", _panelsize );
+    config->writeEntry( "Resizable", _resizable );
 
     KSimpleConfig kdeglobals("kdeglobals", false);
     kdeglobals.setGroup("PanelIcons");
@@ -146,6 +149,17 @@
     config->sync();
 }
 
+void Panel::setResizable( bool resizable )
+{
+    if (!Kicker::kicker()->isImmutable())
+    {
+       _frame->enableResizeHandle( resizable );
+       _resizable=resizable;
+       updateLayout();
+       writeConfig();
+    }
+}
+
 Size Panel::size() const
 {
     if( _panelsize == sizeValue(::Tiny) ) return ::Tiny;
@@ -159,7 +173,7 @@
 {
     _panelsize = QMIN( QMAX( s, MIN_PANEL_SIZE ), MAX_PANEL_SIZE );
 
-    _frame->enableResizeHandle( size() == ::Custom && !Kicker::kicker()->isImmutable() );
+    _frame->enableResizeHandle( _resizable && !Kicker::kicker()->isImmutable() );
 
     updateLayout();
     writeConfig();
diff -urN kicker/core/panel.h kicker_/core/panel.h
--- kicker/core/panel.h	Thu Mar 14 23:01:34 2002
+++ kicker_/core/panel.h	Thu May  2 00:03:35 2002
@@ -69,6 +69,8 @@
     void configure();
 
 public:
+    bool resizable() const { return _resizable; };
+    void setResizable( bool resizable=true );
     Size size() const;
     void setSize( int size );
     QSize sizeHint( Position p, QSize maxSize );
@@ -91,6 +93,7 @@
     void slotResizeRequest( int dx, int dy );
 
 private:
+    bool              _resizable;
     Size              _size;
     int               _panelsize;
     FittsLawFrame*    _frame;
diff -urN kicker/ui/panelop_mnu.cpp kicker_/ui/panelop_mnu.cpp
--- kicker/ui/panelop_mnu.cpp	Sun Mar  3 16:38:31 2002
+++ kicker_/ui/panelop_mnu.cpp	Thu May  2 00:03:35 2002
@@ -54,14 +54,14 @@
     {
         // setup size menu
         sizeMnu = new QPopupMenu(this);
-        sizeMnu->insertItem(i18n("Tiny"), ::Tiny);
-        sizeMnu->insertItem(i18n("Small"), ::Small);
-        sizeMnu->insertItem(i18n("Normal"), ::Normal);
-        sizeMnu->insertItem(i18n("Large"), ::Large);
-        // FIXME: i18n("Custom") + "..." -> i18n("Custom...") after translation unfreeze
-        sizeMnu->insertItem(i18n("Custom") + "...", ::Custom);
+        sizeMnu->insertItem(i18n("Tiny"), this, SLOT(slotSetSize(int)), 0, ::Tiny);
+        sizeMnu->insertItem(i18n("Small"), this, SLOT(slotSetSize(int)), 0, ::Small);
+        sizeMnu->insertItem(i18n("Normal"), this, SLOT(slotSetSize(int)), 0, ::Normal);
+        sizeMnu->insertItem(i18n("Large"), this, SLOT(slotSetSize(int)), 0, ::Large);
+        sizeMnu->insertItem(i18n("Custom"), this, SLOT(slotSetSize(int)), 0, ::Custom);
+        sizeMnu->insertSeparator();
+        sizeMnu->insertItem(i18n("Resizable"), this, SLOT(slotResizableSwitch()), 0, 5);
         connect(sizeMnu, SIGNAL(aboutToShow()), SLOT(slotSetupSizeMnu()));
-        connect(sizeMnu, SIGNAL(activated(int)), SLOT(slotSetSize(int)));
 
         // build menu
         insertItem(i18n("&Add"),
@@ -82,6 +82,11 @@
     adjustSize();
 }
 
+void PanelOpMenu::slotResizableSwitch()
+{
+    _panel->setResizable(!_panel->resizable());
+}
+
 void PanelOpMenu::slotSetupSizeMnu()
 {
     sizeMnu->setItemChecked(::Tiny,false);
@@ -90,18 +95,17 @@
     sizeMnu->setItemChecked(::Large,false);
     sizeMnu->setItemChecked(::Custom,false);
     sizeMnu->setItemChecked(_panel->size(),true);
+    sizeMnu->setItemChecked(5,_panel->resizable());
+    if( static_cast<Size>(_panel->size()) == ::Custom ) {
+        sizeMnu->setItemEnabled(::Custom, true);
+    } else {
+        sizeMnu->setItemEnabled(::Custom, false);
+    }
 }
 
 void PanelOpMenu::slotSetSize(int size)
 {
     if( static_cast<Size>(size) == ::Custom ) {
-        bool ok = false;
-        QIntValidator validator( MIN_PANEL_SIZE, MAX_PANEL_SIZE, 0 );
-        // FIXME: i18n("Size") + ":" -> i18n("Size:") after translation unfreeze
-        QString result = KLineEditDlg::getText( i18n("Size") + ":",
-             QString::number(_panel->panelSize()), &ok, _panel, &validator );
-        if( !ok ) return;
-        _panel->setSize( result.toInt() );
     } else {
         _panel->setSize(sizeValue(static_cast<Size>(size)));
     }
diff -urN kicker/ui/panelop_mnu.h kicker_/ui/panelop_mnu.h
--- kicker/ui/panelop_mnu.h	Sat Mar  2 22:35:40 2002
+++ kicker_/ui/panelop_mnu.h	Thu May  2 00:03:35 2002
@@ -37,6 +37,7 @@
     PanelOpMenu( ::Panel* panel, QWidget* parent );
 
 protected slots:
+    void slotResizableSwitch();
     void slotSetupSizeMnu();
     void slotSetSize(int);
     void slotConfigure();

>> Visit http://mail.kde.org/mailman/listinfo/kde-devel#unsub to unsubscribe <<

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic