Fix taskbar configuration issues

Fix Kicker menu button layout in Deep Buttons mode
pull/2/head
Timothy Pearson 11 years ago
parent 18f6f27f9f
commit a0d0b876b6

@ -36,6 +36,7 @@
#include <kmessagebox.h>
#include <knuminput.h>
#include <kstandarddirs.h>
#include <kfontrequester.h>
#include <kicondialog.h>
#include <kiconloader.h>
@ -198,6 +199,8 @@ void MenuTab::menuStyleChanged()
void MenuTab::save()
{
bool forceRestart = false;
KSharedConfig::Ptr c = KSharedConfig::openConfig(KickerConfig::the()->configName());
c->setGroup("menus");
@ -226,19 +229,37 @@ void MenuTab::save()
bool kmenusetting = m_comboMenuStyle->currentItem()==1;
bool oldkmenusetting = c->readBoolEntry("LegacyKMenu", true);
c->setGroup("KMenu");
bool oldmenutextenabledsetting = c->readBoolEntry("ShowText", true);
TQString oldmenutextsetting = c->readEntry("Text", "");
c->setGroup("buttons");
TQFont oldmenufontsetting = c->readFontEntry("Font");
c->writeEntry("LegacyKMenu", kmenusetting);
c->writeEntry("OpenOnHover", m_openOnHover->isChecked());
c->sync();
if (kmenusetting != oldkmenusetting)
DCOPRef ("kicker", "default").call("restart()");
if (kmenusetting != oldkmenusetting) {
forceRestart = true;
}
if (kcfg_ShowKMenuText->isChecked() != oldmenutextenabledsetting) {
forceRestart = true;
}
if (kcfg_KMenuText->text() != oldmenutextsetting) {
forceRestart = true;
}
if (kcfg_ButtonFont->font() != oldmenufontsetting) {
forceRestart = true;
}
c->setGroup("KMenu");
bool sidepixmapsetting = kcfg_UseSidePixmap->isChecked();
bool oldsidepixmapsetting = c->readBoolEntry("UseSidePixmap", true);
if (sidepixmapsetting != oldsidepixmapsetting)
DCOPRef ("kicker", "default").call("restart()");
if (sidepixmapsetting != oldsidepixmapsetting) {
forceRestart = true;
}
// Save KMenu settings
c->setGroup("KMenu");
@ -253,6 +274,10 @@ void MenuTab::save()
config->sync();
if (m_kmenu_button_changed == true) {
forceRestart = true;
}
if (forceRestart) {
DCOPRef ("kicker", "default").call("restart()");
}
}

@ -21,6 +21,8 @@
#include <tqlayout.h>
#include <tqtimer.h>
#include <tqvaluelist.h>
#include <tqfile.h>
#include <tqlabel.h>
#include <dcopclient.h>
@ -31,7 +33,7 @@
#include <kgenericfactory.h>
#include <twin.h>
#include <kcolorbutton.h>
#include <tqlabel.h>
#include <kstandarddirs.h>
#define protected public
#include "kcmtaskbarui.h"
@ -161,7 +163,24 @@ TaskbarConfig::TaskbarConfig(TQWidget *parent, const char* name, const TQStringL
{
m_configFileName = args[0];
m_widget->globalConfigWarning->hide();
m_widget->globalConfigReload->show();
}
else
{
m_widget->globalConfigReload->hide();
m_widget->globalConfigWarning->show();
}
connect(m_widget->globalConfigReload, TQT_SIGNAL(clicked()), this, TQT_SLOT(slotReloadConfigurationFromGlobals()));
TQFile configFile(locateLocal("config", m_configFileName));
if (!configFile.exists())
{
KConfig globalConfig(GLOBAL_TASKBAR_CONFIG_FILE_NAME, TRUE, TRUE);
KConfig localConfig(m_configFileName);
globalConfig.copyTo(m_configFileName, &localConfig);
localConfig.sync();
}
m_settingsObject = new TaskBarSettings(KSharedConfig::openConfig(m_configFileName));
m_settingsObject->readConfig();
@ -240,6 +259,14 @@ TaskbarConfig::~TaskbarConfig()
}
}
void TaskbarConfig::slotReloadConfigurationFromGlobals()
{
KConfig globalConfig(GLOBAL_TASKBAR_CONFIG_FILE_NAME, TRUE, TRUE);
globalConfig.copyTo(m_configFileName);
m_settingsObject->readConfig();
load();
}
void TaskbarConfig::slotUpdateCustomColors()
{
m_widget->kcfg_ActiveTaskTextColor->setEnabled(m_widget->kcfg_UseCustomColors->isChecked());

@ -70,6 +70,9 @@ protected slots:
void notChanged();
void slotUpdateCustomColors();
private slots:
void slotReloadConfigurationFromGlobals();
private:
TaskbarAppearance::List m_appearances;
void updateAppearanceCombo();

@ -462,16 +462,34 @@ By default, this option is selected and all windows are shown.</string>
</widget>
</grid>
</widget>
<widget class="TQLabel" rowspan="1" colspan="2">
<widget class="TQGroupBox">
<property name="name">
<cstring>globalConfigWarning</cstring>
<cstring>GroupBox2</cstring>
</property>
<property name="text">
<string>NOTE: This module is currently editing the global floating taskbar configuration.&lt;br&gt;To change the configuration of a specific Kicker taskbar applet, please use the Configure Taskbar menu option.</string>
</property>
<property name="buddy" stdset="0">
<cstring>kcfg_ShowTaskStates</cstring>
<property name="title">
<string>Settings</string>
</property>
<grid>
<property name="name">
<cstring>unnamed</cstring>
</property>
<widget class="TQLabel" rowspan="1" colspan="2">
<property name="name">
<cstring>globalConfigWarning</cstring>
</property>
<property name="text">
<string>NOTE: This module is currently editing the global floating taskbar configuration.&lt;br&gt;To change the configuration of a specific Kicker taskbar applet, please use the Configure Taskbar menu option.</string>
</property>
</widget>
<widget class="TQPushButton" rowspan="1" colspan="2">
<property name="name">
<cstring>globalConfigReload</cstring>
</property>
<property name="text">
<string>Use current global floating taskbar configuration</string>
</property>
</widget>
</grid>
</widget>
<spacer>
<property name="name">

@ -310,8 +310,8 @@ int PanelButton::widthForHeight(int height) const
//f.setPixelSize(KMIN(height, KMAX(int(float(height) * m_fontPercent), 16)));
TQFontMetrics fm(f);
//rc += fm.width(m_buttonText) + KMIN(25, KMAX(5, fm.width('m') / 2));
rc += fm.width(m_buttonText);
rc += fm.width(m_buttonText) + ((KMIN(25, KMAX(5, fm.width('m') / 2)))/2);
//rc += fm.width(m_buttonText);
}
return rc;
@ -372,7 +372,7 @@ bool PanelButton::hasText() const
void PanelButton::setButtonText(const TQString& text)
{
m_buttonText = " " + text;
m_buttonText = text;
update();
}
@ -623,7 +623,16 @@ void PanelButton::drawButtonLabel(TQPainter *p, int voffset, bool drawArrow)
TQPixmap icon = labelIcon();
bool active = isDown() || isOn();
if (active)
int offsetX = 0;
int offsetY = 0;
if (active && KickerSettings::showDeepButtons())
{
offsetX = style().pixelMetric(TQStyle::PM_ButtonShiftHorizontal);
offsetY = style().pixelMetric(TQStyle::PM_ButtonShiftVertical);
}
if (active && !KickerSettings::showDeepButtons())
{
icon = TQImage(icon.convertToImage()).smoothScale(icon.width() - 2,
icon.height() - 2);
@ -643,7 +652,7 @@ void PanelButton::drawButtonLabel(TQPainter *p, int voffset, bool drawArrow)
TQFont f = font();
double fontPercent = m_fontPercent;
if (active)
if (active && !KickerSettings::showDeepButtons())
{
fontPercent *= .8;
}
@ -658,7 +667,7 @@ void PanelButton::drawButtonLabel(TQPainter *p, int voffset, bool drawArrow)
if (!reverse && !icon.isNull())
{
/* Draw icon */
p->drawPixmap(3, y+voffset, icon);
p->drawPixmap(offsetX+3, offsetY+y+voffset, icon);
}
int tX = reverse ? 3 : icon.width() + KMIN(25, KMAX(5, fm.width('m') / 2));
@ -677,7 +686,7 @@ void PanelButton::drawButtonLabel(TQPainter *p, int voffset, bool drawArrow)
pixPainter.begin(&textPixmap);
pixPainter.setPen(m_textColor);
pixPainter.setFont(p->font()); // get the font from the root painter
pixPainter.drawText(tX, tY, m_buttonText, -1, rtl);
pixPainter.drawText(offsetX+tX, offsetY+tY, m_buttonText, -1, rtl);
pixPainter.end();
if (!s_textShadowEngine)
@ -692,15 +701,15 @@ void PanelButton::drawButtonLabel(TQPainter *p, int voffset, bool drawArrow)
// draw shadow
TQImage img = s_textShadowEngine->makeShadow(textPixmap, shadCol);
p->drawImage(0, 0, img);
p->drawImage(offsetX, offsetY, img);
p->save();
p->setPen(m_textColor);
p->drawText(tX, tY+voffset, m_buttonText, -1, rtl);
p->drawText(offsetX+tX, offsetY+tY+voffset, m_buttonText, -1, rtl);
p->restore();
if (reverse && !icon.isNull())
{
p->drawPixmap(w - icon.width() - 3, y+voffset, icon);
p->drawPixmap(offsetX + w - icon.width() - 3, offsetY+y+voffset, icon);
}
p->restore();
@ -712,7 +721,7 @@ void PanelButton::drawButtonLabel(TQPainter *p, int voffset, bool drawArrow)
x = (width() - icon.width()) / 2;
else if (m_iconAlignment & AlignRight)
x = (width() - icon.width());
p->drawPixmap(x, y+voffset, icon);
p->drawPixmap(offsetX+x, offsetY+y+voffset, icon);
}
if (m_drawArrow && (m_highlight || active) && drawArrow)

@ -23,11 +23,13 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include <tqlayout.h>
#include <tqtimer.h>
#include <tqfile.h>
#include <dcopclient.h>
#include <kapplication.h>
#include <kdebug.h>
#include <kiconloader.h>
#include <kstandarddirs.h>
#include <twindowlistmenu.h>
#include <X11/X.h>
@ -57,6 +59,14 @@ TaskBarContainer::TaskBarContainer( bool enableFrame, TQString configFileOverrid
{
configFile = GLOBAL_TASKBAR_CONFIG_FILE_NAME;
}
TQFile configFileObject(locateLocal("config", configFile));
if (!configFileObject.exists())
{
KConfig globalConfig(GLOBAL_TASKBAR_CONFIG_FILE_NAME, TRUE, TRUE);
KConfig localConfig(configFile);
globalConfig.copyTo(configFile, &localConfig);
localConfig.sync();
}
settingsObject = new TaskBarSettings(KSharedConfig::openConfig(configFile));
setBackgroundOrigin( AncestorOrigin );

@ -661,7 +661,7 @@ void TaskContainer::drawButton(TQPainter *p)
// draw button background
if (drawButton)
{
if (KickerSettings::showDeepButtons()) {
if (m_settingsObject->drawButtons() && KickerSettings::showDeepButtons()) {
style().tqdrawPrimitive(TQStyle::PE_ButtonBevel, p,
TQRect(1, 1, width()-3, height()-2),
colors, sunken ? TQStyle::Style_On : TQStyle::Style_Raised);
@ -770,7 +770,7 @@ void TaskContainer::drawButton(TQPainter *p)
}
}
int availableWidth = width() - (br.x() * 2) - textPos - 2 - KickerSettings::showDeepButtons()?2:0;
int availableWidth = width() - (br.x() * 2) - textPos - 2 - (m_settingsObject->drawButtons() && KickerSettings::showDeepButtons())?2:0;
if (m_filteredTasks.count() > 1)
{
availableWidth -= 8;
@ -846,7 +846,7 @@ void TaskContainer::drawButton(TQPainter *p)
}
// draw popup arrow
if ((m_filteredTasks.count() > 1) && (!KickerSettings::showDeepButtons()))
if ((m_filteredTasks.count() > 1) && (!(m_settingsObject->drawButtons() && KickerSettings::showDeepButtons())))
{
TQStyle::PrimitiveElement e = TQStyle::PE_ArrowLeft;

Loading…
Cancel
Save