From 4c5193dab9b38eedbb07a37da7c4858cf551d764 Mon Sep 17 00:00:00 2001 From: ketmar Date: Sun, 8 Jan 2012 22:37:20 +0200 Subject: [PATCH] mplayer hack now can be activated in preferences dialog --- src/jcfg.cpp | 4 +++- src/jcfg.h | 3 ++- src/jrugr.cpp | 18 +++++++++++++----- src/jrugr.h | 1 + src/jrugrconfui.cpp | 9 ++++++++- src/jrugrconfui.h | 1 + src/ui/configwin.ui | 17 ++++++++++++----- 7 files changed, 40 insertions(+), 13 deletions(-) diff --git a/src/jcfg.cpp b/src/jcfg.cpp index aafc9ba..82352d9 100644 --- a/src/jcfg.cpp +++ b/src/jcfg.cpp @@ -38,12 +38,13 @@ JrugrCfg *JrugrCfg::load (const QString &fname) { // res->showFlag = qcfg.value("showflag", true).toBool(); res->useSU = qcfg.value("useSU", true).toBool(); + res->mplayerHack = qcfg.value("mplayerHack", false).toBool(); qcfg.endGroup(); return res; } -bool JrugrCfg::save (const QString &fname) { +bool JrugrCfg::save (const QString &fname) const { LayoutUnit lu; QSettings qcfg(fname, QSettings::IniFormat); QString layout, variant; @@ -63,6 +64,7 @@ bool JrugrCfg::save (const QString &fname) { qcfg.setValue("showflag", showFlag); qcfg.setValue("switching", switching); qcfg.setValue("useSU", useSU); + qcfg.setValue("mplayerHack", mplayerHack); qcfg.setValue("option", options.join(",")); qcfg.endGroup(); return true; diff --git a/src/jcfg.h b/src/jcfg.h index 2708513..9280a74 100644 --- a/src/jcfg.h +++ b/src/jcfg.h @@ -29,7 +29,7 @@ public: JrugrCfg () : workMode(ONLY_INDICATION), switching(GLOBAL_LAYOUT), showFlag(true), useSU(true) {} static JrugrCfg *load (const QString &fname); - bool save (const QString &fname); + bool save (const QString &fname) const; public: QString model; @@ -39,6 +39,7 @@ public: JSwitchMode switching; bool showFlag; bool useSU; + bool mplayerHack; }; diff --git a/src/jrugr.cpp b/src/jrugr.cpp index fd7933c..6514fdc 100644 --- a/src/jrugr.cpp +++ b/src/jrugr.cpp @@ -94,6 +94,7 @@ void Jrugr::startup () { jCfg = JrugrCfg::load(mCfgFileName); if (!jCfg) abort(); if (jCfg->workMode == USE_XKB) configureXkb(); + mMplayerHack = jCfg->mplayerHack; // mXkb = new XKeyboard(); mXkb->groupInfo(mGroupInfo); @@ -117,6 +118,7 @@ void Jrugr::startup () { void Jrugr::initialize () { mXkb->groupInfo(mGroupInfo); // + mMplayerHack = jCfg->mplayerHack; mActiveGroup = mXkb->activeGroup(); mActiveWindow = X11Tools::activeWindow(); mCurDesk = X11Tools::activeDesktop(); @@ -145,9 +147,11 @@ void Jrugr::reconfigure () { } // if (diffGI || newConf->layouts != jCfg->layouts || newConf->showFlag != jCfg->showFlag || - newConf->workMode != jCfg->workMode || newConf->switching != jCfg->switching) { + newConf->workMode != jCfg->workMode || newConf->switching != jCfg->switching || + mMplayerHack != newConf->mplayerHack) { delete jCfg; jCfg = newConf; + mMplayerHack = jCfg->mplayerHack; createMenu(); buildIcon(); } else { @@ -636,7 +640,9 @@ void Jrugr::onActiveWindowChanged (Window w) { #ifdef K8_MPLAYER_HACK if (mDeskJustChanged) { //deactivateMPlayer(); - mMPFix->start(MPLAYER_HACK_TIMEOUT); + if (mMplayerHack) { + mMPFix->start(MPLAYER_HACK_TIMEOUT); + } mDeskJustChanged = false; } #else @@ -653,7 +659,7 @@ void Jrugr::onActiveWindowChanged (Window w) { qDebug() << "*** mDeskJustChanged ***"; mDeskJustChanged = false; #ifdef K8_MPLAYER_HACK - if (isMPlayer(w)) { + if (mMplayerHack && isMPlayer(w)) { //mMPFix->start(MPLAYER_HACK_TIMEOUT); if (deactivateMPlayer()) return; } @@ -661,7 +667,7 @@ void Jrugr::onActiveWindowChanged (Window w) { } // #ifdef K8_MPLAYER_HACK - if (!isMPlayer(w)) + if (!mMplayerHack || !isMPlayer(w)) #endif setDeskActiveWindow(mCurDesk, w); { @@ -711,7 +717,9 @@ void Jrugr::onActiveDesktopChanged (int desk) { mDeskJustChanged = true; #ifdef K8_MPLAYER_HACK //if (deactivateMPlayer()) mDeskJustChanged = false; - mMPFix->start(MPLAYER_HACK_TIMEOUT); + if (mMplayerHack) { + mMPFix->start(MPLAYER_HACK_TIMEOUT); + } #endif if (jCfg->switching == DESK_LAYOUT && mCurDesk != desk) { int ll = desktopLayout(desk); diff --git a/src/jrugr.h b/src/jrugr.h index 38d8363..f4f53d3 100644 --- a/src/jrugr.h +++ b/src/jrugr.h @@ -135,6 +135,7 @@ private: QString mCfgFileName; // #ifdef K8_MPLAYER_HACK + bool mMplayerHack; QTimer *mMPFix; #endif }; diff --git a/src/jrugrconfui.cpp b/src/jrugrconfui.cpp index 61a45e8..aa7c5ec 100644 --- a/src/jrugrconfui.cpp +++ b/src/jrugrconfui.cpp @@ -31,6 +31,9 @@ JrugrConfigForm::JrugrConfigForm (const QString &optFileName, QWidget *parent) : case DESK_LAYOUT: cfgUI.rbPolicyDesk->setChecked(true); break; } // + connect(cfgUI.chkMPHack, SIGNAL(clicked()), SLOT(setMPHack())); + cfgUI.chkMPHack->setChecked(mJCfg->mplayerHack); + // connect(cfgUI.buttonBox, SIGNAL(rejected()), this, SLOT(close())); connect(cfgUI.buttonBox, SIGNAL(accepted()), SLOT(apply())); connect(cfgUI.rbUseXkb, SIGNAL(clicked(bool)), SLOT(statSelect(bool))); @@ -136,7 +139,6 @@ void JrugrConfigForm::initXKBTab () { bool JrugrConfigForm::setStat () { - cfgUI.chkShowFlag->setChecked(mJCfg->showFlag); connect(cfgUI.chkShowFlag, SIGNAL(clicked()), SLOT(setFlagUse())); // switch (mJCfg->workMode) { @@ -288,6 +290,11 @@ void JrugrConfigForm::setFlagUse () { } +void JrugrConfigForm::setMPHack () { + mJCfg->mplayerHack = cfgUI.chkMPHack->isChecked(); +} + + void JrugrConfigForm::layoutUp () { int row = getSelectedDstLayout(); if (row>0) { diff --git a/src/jrugrconfui.h b/src/jrugrconfui.h index ec38ada..8cc2f4c 100644 --- a/src/jrugrconfui.h +++ b/src/jrugrconfui.h @@ -36,6 +36,7 @@ public slots: void statSelect (bool check); void apply (); void setFlagUse (); + void setMPHack (); void layoutUp (); void layoutDown (); void updateOptionsCommand (); diff --git a/src/ui/configwin.ui b/src/ui/configwin.ui index dd32727..7e499b5 100644 --- a/src/ui/configwin.ui +++ b/src/ui/configwin.ui @@ -79,7 +79,7 @@ Jrugr will start indicator but will use existing layout configuration - Indicator only + Indicator &only true @@ -95,7 +95,7 @@ Jrugr will not configure or show keyboard layouts - Disable keyboard layouts + &Disable keyboard layouts false @@ -123,7 +123,7 @@ Shows country flag on background of layout name in tray icon - Show country flag + Show country &flag true @@ -136,13 +136,20 @@ false - Show indicator for single layout + Show indicator for &single layout true + + + + &MPlayer hack + + + @@ -396,7 +403,7 @@ - Command: + Com&mand: editCmdLine -- 2.11.4.GIT