Commit 50cbcd83 authored by Christian Esken's avatar Christian Esken
Browse files

System tray volume control can now have its own orientation.

BUGS: 248423
parent bd106249
......@@ -428,6 +428,11 @@ KMixWindow::saveBaseConfig()
else
config.writeEntry("Orientation", "Vertical");
if (GlobalConfig::instance().traypopupOrientation == Qt::Horizontal)
config.writeEntry("Orientation.TrayPopup", "Horizontal");
else
config.writeEntry("Orientation.TrayPopup", "Vertical");
kDebug()
<< "Config (Base) saving done";
}
......@@ -556,8 +561,8 @@ KMixWindow::loadBaseConfig()
setBeepOnVolumeChange(config.readEntry("VolumeFeedback", false));
m_startVisible = config.readEntry("Visible", false);
m_multiDriverMode = config.readEntry("MultiDriver", false);
const QString& orientationString = config.readEntry("Orientation",
"Vertical");
const QString& orientationString = config.readEntry("Orientation", "Vertical");
const QString& traypopupOrientationString = config.readEntry("Orientation.TrayPopup", "Vertical");
m_defaultCardOnStart = config.readEntry("DefaultCardOnStart", "");
m_configVersion = config.readEntry("ConfigVersion", 0);
// WARNING Don't overwrite m_configVersion with the "correct" value, before having it
......@@ -587,6 +592,11 @@ KMixWindow::loadBaseConfig()
else
GlobalConfig::instance().toplevelOrientation = Qt::Vertical;
if (traypopupOrientationString == "Horizontal")
GlobalConfig::instance().traypopupOrientation = Qt::Horizontal;
else
GlobalConfig::instance().traypopupOrientation = Qt::Vertical;
// show/hide menu bar
bool showMenubar = config.readEntry("Menubar", true);
......@@ -1213,9 +1223,14 @@ KMixWindow::showSettings()
m_prefDlg->m_showTicks->setChecked(GlobalConfig::instance().showTicks);
m_prefDlg->m_showLabels->setChecked(GlobalConfig::instance().showLabels);
m_prefDlg->m_showOSD->setChecked(GlobalConfig::instance().showOSD);
m_prefDlg->_rbVertical->setChecked(GlobalConfig::instance().toplevelOrientation == Qt::Vertical);
m_prefDlg->_rbHorizontal->setChecked(
GlobalConfig::instance().toplevelOrientation == Qt::Horizontal);
bool toplevelIsVertical = GlobalConfig::instance().toplevelOrientation == Qt::Vertical;
m_prefDlg->_rbVertical->setChecked(toplevelIsVertical);
m_prefDlg->_rbHorizontal->setChecked(!toplevelIsVertical);
bool traypopupIsVertical = GlobalConfig::instance().traypopupOrientation == Qt::Vertical;
m_prefDlg->_rbTraypopupVertical->setChecked(traypopupIsVertical);
m_prefDlg->_rbTraypopupHorizontal->setChecked(!traypopupIsVertical);
// show dialog
m_prefDlg->show();
......@@ -1242,14 +1257,12 @@ void KMixWindow::applyPrefs(KMixPrefDlg *prefDlg)
{
bool labelsHasChanged = GlobalConfig::instance().showLabels ^ prefDlg->m_showLabels->isChecked();
bool ticksHasChanged = GlobalConfig::instance().showTicks ^ prefDlg->m_showTicks->isChecked();
bool dockwidgetHasChanged = m_showDockWidget
^ prefDlg->m_dockingChk->isChecked();
bool systrayPopupHasChanged = trayVolumePopupEnabled
^ prefDlg->m_volumeChk->isChecked();
bool toplevelOrientationHasChanged = (prefDlg->_rbVertical->isChecked()
&& GlobalConfig::instance().toplevelOrientation == Qt::Horizontal)
|| (prefDlg->_rbHorizontal->isChecked()
&& GlobalConfig::instance().toplevelOrientation == Qt::Vertical);
bool dockwidgetHasChanged = m_showDockWidget ^ prefDlg->m_dockingChk->isChecked();
bool systrayPopupHasChanged = trayVolumePopupEnabled ^ prefDlg->m_volumeChk->isChecked();
Qt::Orientation newToplevelOrientation = prefDlg->_rbVertical->isChecked() ? Qt::Vertical : Qt::Horizontal;
bool toplevelOrientationHasChanged = newToplevelOrientation != GlobalConfig::instance().toplevelOrientation;
Qt::Orientation newTraypopupOrientation = prefDlg->_rbTraypopupVertical->isChecked() ? Qt::Vertical : Qt::Horizontal;
bool traypopupOrientationHasChanged = newTraypopupOrientation != GlobalConfig::instance().traypopupOrientation;
GlobalConfig::instance().showLabels = prefDlg->m_showLabels->isChecked();
GlobalConfig::instance().showTicks = prefDlg->m_showTicks->isChecked();
......@@ -1260,24 +1273,18 @@ void KMixWindow::applyPrefs(KMixPrefDlg *prefDlg)
allowAutostart = m_prefDlg->allowAutostart->isChecked();
setBeepOnVolumeChange(prefDlg->m_beepOnVolumeChange->isChecked());
if (prefDlg->_rbVertical->isChecked())
{
GlobalConfig::instance().toplevelOrientation = Qt::Vertical;
}
else if (prefDlg->_rbHorizontal->isChecked())
{
GlobalConfig::instance().toplevelOrientation = Qt::Horizontal;
}
GlobalConfig::instance().toplevelOrientation = newToplevelOrientation;
GlobalConfig::instance().traypopupOrientation = newTraypopupOrientation;
if ( systrayPopupHasChanged || dockwidgetHasChanged || toplevelOrientationHasChanged )
if ( systrayPopupHasChanged)
{
// if the user has changed the "volume popup" option, the KStatusNotifier requires a new referenceWidget,
// thus we force a reconstruct.
forceNotifierRebuild = true;
}
if ( systrayPopupHasChanged || dockwidgetHasChanged || toplevelOrientationHasChanged || traypopupOrientationHasChanged)
{
// These might need a complete relayout => announce a ControlList change to rebuild everything
if ( systrayPopupHasChanged)
{
// if the user has changed the "volume popup" option, the KStatusNotifier requires a new referenceWidget,
// thus we force a reconstruct.
forceNotifierRebuild = true;
}
ControlManager::instance().announce(QString(), ControlChangeType::ControlList, QString("Preferences Dialog"));
}
else if ( labelsHasChanged || ticksHasChanged )
......
......@@ -31,6 +31,7 @@ public:
bool showLabels;
bool showOSD;
Qt::Orientation toplevelOrientation;
Qt::Orientation traypopupOrientation;
void setMixersForSoundmenu(QSet<QString> mixersForSoundmenu) { this->mixersForSoundmenu = mixersForSoundmenu; };
QSet<QString> getMixersForSoundmenu() { return mixersForSoundmenu; };
......@@ -47,6 +48,7 @@ private:
showLabels = true;
showOSD = true;
toplevelOrientation = Qt::Vertical;
traypopupOrientation = Qt::Vertical;
};
static GlobalConfig instanceObj;
......
......@@ -104,8 +104,9 @@ KMixPrefDlg::KMixPrefDlg(QWidget *parent) :
m_showOSD = new QCheckBox(i18n("Show On Screen Display (&OSD)"), m_generalTab);
addWidgetToLayout(m_showOSD, layout, 10, "");
// Slider orientation (main window)
QBoxLayout *orientationLayout = new QHBoxLayout();
orientationLayout->addSpacing(10);
// orientationLayout->addSpacing(10);
layout->addItem(orientationLayout);
QButtonGroup* orientationGroup = new QButtonGroup(m_generalTab);
orientationGroup->setExclusive(true);
......@@ -120,7 +121,26 @@ KMixPrefDlg::KMixPrefDlg(QWidget *parent) :
orientationLayout->addWidget(_rbVertical);
orientationLayout->addStretch();
// Slider orientation (tray popup). We use an extra setting
QBoxLayout *orientation2Layout = new QHBoxLayout();
// orientation2Layout->addSpacing(10);
layout->addItem(orientation2Layout);
QButtonGroup* orientation2Group = new QButtonGroup(m_generalTab);
orientation2Group->setExclusive(true);
QLabel* qlb2 = new QLabel(i18n("Slider orientation (System tray volume control):"), m_generalTab);
_rbTraypopupHorizontal = new QRadioButton(i18n("&Horizontal"), m_generalTab);
_rbTraypopupVertical = new QRadioButton(i18n("&Vertical"), m_generalTab);
orientation2Group->addButton(_rbTraypopupVertical);
orientation2Group->addButton(_rbTraypopupHorizontal);
orientation2Layout->addWidget(qlb2);
orientation2Layout->addWidget(_rbTraypopupVertical);
orientation2Layout->addWidget(_rbTraypopupHorizontal);
layout->addStretch();
showButtonSeparator(true);
connect(this, SIGNAL(applyClicked()), SLOT(apply()));
......
......@@ -74,6 +74,8 @@ KMixPrefDlg : public KDialog
QLabel *volumeFeedbackWarning;
QRadioButton *_rbVertical;
QRadioButton *_rbHorizontal;
QRadioButton *_rbTraypopupVertical;
QRadioButton *_rbTraypopupHorizontal;
};
#endif // KMIXPREFDLG_H
......@@ -236,7 +236,7 @@ void ViewDockAreaPopup::_setMixSet()
QWidget* ViewDockAreaPopup::add(shared_ptr<MixDevice> md)
{
bool vertical = (GlobalConfig::instance().toplevelOrientation == Qt::Vertical); // I am wondering whether using vflags for this would still make sense
bool vertical = (GlobalConfig::instance().traypopupOrientation == Qt::Vertical); // I am wondering whether using vflags for this would still make sense
QString dummyMatchAll("*");
QString matchAllPlaybackAndTheCswitch("pvolume,cvolume,pswitch,cswitch");
......@@ -268,7 +268,7 @@ _layoutMDW->addWidget( seperatorBetweenMastersAndStreams, row, col );
true, // Show Mute LE
true, // Show Record LED
false, // Small
GlobalConfig::instance().toplevelOrientation,
GlobalConfig::instance().traypopupOrientation,
this, // parent
this // NOT ANYMORE!!! -> Is "NULL", so that there is no RMB-popup
, pctl
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment