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

List:       kde-commits
Subject:    KDE/kdemultimedia/kmix
From:       Aurélien Gâteau <agateau () kde ! org>
Date:       2010-12-17 14:39:10
Message-ID: 20101217143910.27681AC8A8 () svn ! kde ! org
[Download RAW message or body]

SVN commit 1207315 by gateau:

Start with a decently sized window

CCMAIL:esken@kde.org

 M  +25 -25    apps/kmix.cpp  
 M  +1 -1      apps/kmix.h  
 M  +3 -4      gui/mdwslider.cpp  


--- trunk/KDE/kdemultimedia/kmix/apps/kmix.cpp #1207314:1207315
@@ -95,6 +95,10 @@
     initActionsAfterInitMixer(); // init actions that require initialized mixer \
backend(s).  
     recreateGUI(false);
+
+    if ( !kapp->isSessionRestored() ) // done by the session manager otherwise
+        setInitialSize();
+
     fixConfigAfterRead();
     theKMixDeviceManager->initHotplug();
     connect(theKMixDeviceManager, SIGNAL( plugged( const char*, const QString&, \
QString&)), SLOT (plugged( const char*, const QString&, QString&) ) ); @@ -198,16 \
+202,9 @@  
 void KMixWindow::initWidgets()
 {
-    // Main widget and layout
-    setCentralWidget( new QWidget( this ) );
-
-    // Widgets layout
-    m_widgetsLayout = new QVBoxLayout(   centralWidget()   );
-    m_widgetsLayout->setObjectName( QLatin1String(   "m_widgetsLayout" )   );
-    m_widgetsLayout->setSpacing(   0   );
-    m_widgetsLayout->setMargin (   0   );
-
-    m_wsMixers = new KTabWidget( centralWidget() );
+    m_wsMixers = new KTabWidget();
+    m_wsMixers->setDocumentMode(true);
+    setCentralWidget(m_wsMixers);
     m_wsMixers->setTabsClosable(true);
     connect (m_wsMixers, SIGNAL(tabCloseRequested(int)), SLOT(saveAndCloseView(int)) \
);  
@@ -220,12 +217,27 @@
 
     connect( m_wsMixers, SIGNAL( currentChanged ( int ) ), SLOT( newMixerShown(int)) \
);  
-    m_widgetsLayout->addWidget(m_wsMixers);
-
     // show menubar if the actions says so (or if the action does not exist)
     menuBar()->setVisible( (_actionShowMenubar==0) || \
_actionShowMenubar->isChecked()); +}
 
-    m_widgetsLayout->activate();
+
+void KMixWindow::setInitialSize()
+{
+    KConfigGroup config(KGlobal::config(), "Global");
+
+    // HACK: QTabWidget will bound its sizeHint to 200x200 unless scrollbuttons
+    // are disabled, so we disable them, get a decent sizehint and enable them
+    // back
+    m_wsMixers->setUsesScrollButtons(false);
+    QSize defSize = sizeHint();
+    m_wsMixers->setUsesScrollButtons(true);
+    QSize size = config.readEntry("Size", defSize );
+    if(!size.isEmpty()) resize(size);
+
+    QPoint defPos = pos();
+    QPoint pos = config.readEntry("Position", defPos);
+    move(pos);
 }
 
 
@@ -410,19 +422,7 @@
     bool showMenubar = config.readEntry("Menubar", true);
 
     if (_actionShowMenubar) _actionShowMenubar->setChecked( showMenubar );
-
-    // restore window size and position
-    if ( !kapp->isSessionRestored() ) // done by the session manager otherwise
-    {
-        QSize defSize( minimumWidth(), height() );
-        QSize size = config.readEntry("Size", defSize );
-        if(!size.isEmpty()) resize(size);
-
-        QPoint defPos = pos();
-        QPoint pos = config.readEntry("Position", defPos);
-        move(pos);
     }
-}
 
 /**
  * Loads the volumes of all mixers from kmixctrlrc.
--- trunk/KDE/kdemultimedia/kmix/apps/kmix.h #1207314:1207315
@@ -123,7 +123,6 @@
    QString m_hwInfoString;
    QString m_defaultCardOnStart;
    bool m_dontSetDefaultCardOnStart;
-   QVBoxLayout *m_widgetsLayout;
    QLabel      *m_errorLabel;
    ViewDockAreaPopup *_dockAreaPopup;
    unsigned int m_configVersion;
@@ -133,6 +132,7 @@
    OSDWidget* osdWidget;
 
    bool addMixerWidget(const QString& mixer_ID, GUIProfile *guiprof, int \
insertPosition); +   void setInitialSize();
 
   private slots:
    void saveConfig();
--- trunk/KDE/kdemultimedia/kmix/gui/mdwslider.cpp #1207314:1207315
@@ -49,7 +49,6 @@
 #include "verticaltext.h"
 #include "mdwmoveaction.h"
 
-static const int MIN_SLIDER_SIZE = 50;
 
 /**
  * MixDeviceWidget that represents a single mix device, inlcuding PopUp, muteLED, \
... @@ -280,7 +279,6 @@
 		controlLayout->setAlignment(Qt::AlignHCenter|Qt::AlignTop);
 		setLayout(controlLayout);
         controlLayout->setContentsMargins(0,0,0,0);
-        controlLayout->setSpacing(0);
 
 		//add device icon
 		m_iconLabelSimple = 0L;
@@ -501,6 +499,7 @@
 
 	}
 
+	const int minSliderSize = fontMetrics().height() * 10;
 	for ( int i=0; i<= Volume::CHIDMAX; i++ ) {
 		if ( vol._chmask & Volume::_channelMaskEnum[i] ) {
 			Volume::ChannelID chid = Volume::ChannelID(i);
@@ -522,10 +521,10 @@
 				sliderBig->setValue( maxvol - vol.getVolume( chid ) );
 
 				if ( _orientation == Qt::Vertical ) {
-					sliderBig->setMinimumHeight( MIN_SLIDER_SIZE );
+					sliderBig->setMinimumHeight( minSliderSize );
 				}
 				else {
-					sliderBig->setMinimumWidth( MIN_SLIDER_SIZE );
+					sliderBig->setMinimumWidth( minSliderSize );
 				}
 				if ( ! _pctl->getBackgroundColor().isEmpty() ) {
 				    QString bcolor(_pctl->getBackgroundColor());


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

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