[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: extragear/utils/kpager
From: Pino Toscano <pino () kde ! org>
Date: 2011-01-01 1:12:18
Message-ID: 20110101011218.5DB25AC8AE () svn ! kde ! org
[Download RAW message or body]
SVN commit 1210530 by pino:
migrate almost all the configuration to kconfigxt
what is left out of it (hence doing manual read/write from the configuration group) \
are the per-layout width/height values, but now they share the same configuration \
object of kconfigxt, so there's less chance to step on each other's toes
M +1 -0 CMakeLists.txt
M +16 -50 config.cpp
M +0 -16 config.h
M +10 -22 desktop.cpp
M +0 -7 desktop.h
M +8 -22 kpager.cpp
M +0 -3 kpager.h
A kpager.kcfg
A settings.kcfgc
--- trunk/extragear/utils/kpager/CMakeLists.txt #1210529:1210530
@@ -17,6 +17,7 @@
ksharedpixmap.cpp
main.cpp )
qt4_add_dbus_adaptor( kpager_SRCS org.kde.KPager.xml kpager.h KPagerMainWindow )
+kde4_add_kcfg_files(kpager_SRCS settings.kcfgc)
kde4_add_executable(kpager ${kpager_SRCS})
--- trunk/extragear/utils/kpager/config.cpp #1210529:1210530
@@ -41,6 +41,7 @@
#include "config.moc"
#include "desktop.h"
#include "kpager.h"
+#include <settings.h>
KPagerConfigDialog::KPagerConfigDialog (QWidget *parent)
: KDialog( parent )
@@ -111,87 +112,52 @@
void KPagerConfigDialog::setShowName(bool show)
{
- m_tmpShowName=show;
+ Settings::setShowName(show);
}
void KPagerConfigDialog::setShowNumber(bool show)
{
- m_tmpShowNumber=show;
+ Settings::setShowNumber(show);
}
void KPagerConfigDialog::setShowBackground(bool show)
{
- m_tmpShowBackground=show;
+ Settings::setShowBackground(show);
}
void KPagerConfigDialog::setShowWindows(bool show)
{
- m_tmpShowWindows=show;
+ Settings::setShowWindows(show);
}
void KPagerConfigDialog::enableWindowDragging(bool enable)
{
- m_tmpWindowDragging = enable;
+ Settings::setWindowDragging(enable);
}
void KPagerConfigDialog::setWindowDrawMode(int type)
{
- m_tmpWindowDrawMode=type;
+ Settings::setWindowDrawMode(type);
}
void KPagerConfigDialog::setLayout(int layout)
{
- m_tmpLayoutType=layout;
+ Settings::setLayoutType(layout);
}
void KPagerConfigDialog::loadConfiguration()
{
- m_chkShowName->setChecked(m_showName);
- m_chkShowNumber->setChecked(m_showNumber);
- m_chkShowBackground->setChecked(m_showBackground);
- m_chkShowWindows->setChecked(m_showWindows);
- m_grpWindowDrawMode->button(m_windowDrawMode)->setChecked(true);
- m_grpLayoutType->button(m_layoutType)->setChecked(true);
- m_chkWindowDragging->setChecked( m_windowDragging );
- m_tmpShowName=m_showName;
- m_tmpShowNumber=m_showNumber;
- m_tmpShowBackground=m_showBackground;
- m_tmpShowWindows=m_showWindows;
- m_tmpWindowDrawMode=m_windowDrawMode;
- m_tmpLayoutType=m_layoutType;
- m_tmpWindowDragging=m_windowDragging;
+ m_chkShowName->setChecked(Settings::showName());
+ m_chkShowNumber->setChecked(Settings::showNumber());
+ m_chkShowBackground->setChecked(Settings::showBackground());
+ m_chkShowWindows->setChecked(Settings::showWindows());
+ m_grpWindowDrawMode->button(Settings::windowDrawMode())->setChecked(true);
+ m_grpLayoutType->button(Settings::layoutType())->setChecked(true);
+ m_chkWindowDragging->setChecked(Settings::windowDragging());
}
-void KPagerConfigDialog::initConfiguration(void)
-{
- KConfigGroup cfg(KGlobal::config(), "KPager");
-
- m_windowDrawMode=cfg.readEntry("windowDrawMode", \
int(Desktop::c_defWindowDrawMode));
- m_showName=cfg.readEntry("showName", Desktop::c_defShowName);
- m_showNumber=cfg.readEntry("showNumber", Desktop::c_defShowNumber);
- m_showBackground=cfg.readEntry("showBackground", Desktop::c_defShowBackground);
- m_showWindows=cfg.readEntry("showWindows", Desktop::c_defShowWindows);
- m_layoutType=cfg.readEntry("layoutType", int(KPager::c_defLayout));
- m_windowDragging=cfg.readEntry("windowDragging", true);
-}
-
void KPagerConfigDialog::slotOk()
{
- m_showName=m_tmpShowName;
- m_showNumber=m_tmpShowNumber;
- m_showBackground=m_tmpShowBackground;
- m_showWindows=m_tmpShowWindows;
- m_windowDrawMode=m_tmpWindowDrawMode;
- m_layoutType=m_tmpLayoutType;
- m_windowDragging=m_tmpWindowDragging;
+ Settings::self()->writeConfig();
accept();
}
-
-bool KPagerConfigDialog::m_showName=Desktop::c_defShowName;
-bool KPagerConfigDialog::m_showNumber=Desktop::c_defShowNumber;
-bool KPagerConfigDialog::m_showBackground=Desktop::c_defShowBackground;
-bool KPagerConfigDialog::m_showWindows=Desktop::c_defShowWindows;
-bool KPagerConfigDialog::m_windowDragging=Desktop::c_defWindowDragging;
-int KPagerConfigDialog::m_windowDrawMode=Desktop::c_defWindowDrawMode;
-int KPagerConfigDialog::m_layoutType=KPager::c_defLayout;
-
--- trunk/extragear/utils/kpager/config.h #1210529:1210530
@@ -48,15 +48,6 @@
void loadConfiguration();
void slotOk();
-public:
- static void initConfiguration(void);
- static bool m_showName;
- static bool m_showNumber;
- static bool m_showBackground;
- static bool m_showWindows;
- static int m_windowDrawMode;
- static int m_layoutType;
- static bool m_windowDragging;
protected:
QCheckBox *m_chkShowName;
@@ -66,13 +57,6 @@
QButtonGroup *m_grpWindowDrawMode;
QButtonGroup *m_grpLayoutType;
QCheckBox* m_chkWindowDragging;
- bool m_tmpShowName;
- bool m_tmpShowNumber;
- bool m_tmpShowBackground;
- bool m_tmpShowWindows;
- int m_tmpWindowDrawMode;
- int m_tmpLayoutType;
- bool m_tmpWindowDragging;
};
#endif
--- trunk/extragear/utils/kpager/desktop.cpp #1210529:1210530
@@ -51,6 +51,7 @@
#include "config.h"
#include "windowdrag.h"
#include <QX11Info>
+#include <settings.h>
Desktop::Desktop( int desk, const QString &desktopName, QWidget *parent): \
QWidget(parent) {
@@ -64,10 +65,7 @@
setAcceptDrops(true);
setAttribute(Qt::WA_NoSystemBackground, true);
- KSharedConfig::Ptr cfg = KGlobal::config();
- KConfigGroup grp(cfg,"KPager");
- m_transparentMode=static_cast<WindowTransparentMode>
- (grp.readEntry("windowTransparentMode", int(c_defWindowTransparentMode)));
+ m_transparentMode = \
static_cast<WindowTransparentMode>(Settings::windowTransparentMode()); resize(67, \
50); }
@@ -79,7 +77,7 @@
void Desktop::mouseMoveEvent( QMouseEvent *ev )
{
- if ( !KPagerConfigDialog::m_windowDragging )
+ if ( !Settings::windowDragging() )
return;
if ( (ev->buttons() & Qt::LeftButton) == 0 )
return;
@@ -90,7 +88,7 @@
void Desktop::mousePressEvent( QMouseEvent * ev)
{
- bool showWindows= KPagerConfigDialog::m_showWindows;
+ const bool showWindows = Settings::showWindows();
if (ev->button()==Qt::LeftButton){
pressPos = ev->pos();
}
@@ -112,7 +110,7 @@
to drop a window in this desktop */
if (ev->button()==Qt::LeftButton)
{
- bool showWindows= KPagerConfigDialog::m_showWindows;
+ const bool showWindows = Settings::showWindows();
QPoint pos;
KWindowSystem::setCurrentDesktop(m_desk);
if (showWindows)
@@ -247,7 +245,7 @@
void Desktop::paintWindow(QPainter &p, const KWindowInfo *info, bool onDesktop)
{
- switch (static_cast<WindowDrawMode>(KPagerConfigDialog::m_windowDrawMode ) )
+ switch (static_cast<WindowDrawMode>(Settings::windowDrawMode()) )
{
case (Plain) : paintWindowPlain (p, info, onDesktop);break;
case (Icon) : paintWindowIcon (p, info, onDesktop);break;
@@ -412,7 +410,7 @@
// p.setPen(Qt::black);
// p.drawRect(rect());
- if (KPagerConfigDialog::m_showBackground )
+ if (Settings::showBackground())
{
if ( ( !m_isCommon && !m_bgSmallPixmap )
|| (m_isCommon && !m_bgCommonSmallPixmap) )
@@ -442,8 +440,8 @@
p.setPen(QPalette::Base);
// paint number & name
- bool sname=KPagerConfigDialog::m_showName;
- bool snumber=KPagerConfigDialog::m_showNumber;
+ bool sname = Settings::showName();
+ bool snumber = Settings::showNumber();
if ( sname || snumber ) {
QString txt;
@@ -468,7 +466,7 @@
}
// paint windows
- if ( KPagerConfigDialog::m_showWindows ) {
+ if ( Settings::showWindows() ) {
foreach( WId w, KWindowSystem::stackingOrder()) {
KWindowInfo* info = pager()->info( w );
if (shouldPaintWindow(info))
@@ -673,14 +671,4 @@
QHash<WId, QPixmap> Desktop::m_windowPixmaps;
QMap<int,bool> Desktop::m_windowPixmapsDirty;
-// Default Configuration -------------------------------------------------
-
-const bool Desktop::c_defShowName=false;
-const bool Desktop::c_defShowNumber=false;
-const bool Desktop::c_defShowWindows=true;
-const bool Desktop::c_defShowBackground=true;
-const bool Desktop::c_defWindowDragging=true;
-const Desktop::WindowDrawMode Desktop::c_defWindowDrawMode=Desktop::Icon;
-const Desktop::WindowTransparentMode
- Desktop::c_defWindowTransparentMode=Desktop::AllWindows;
#include "desktop.moc"
--- trunk/extragear/utils/kpager/desktop.h #1210529:1210530
@@ -54,15 +54,8 @@
// int widthForHeight(int height) const;
// int heightForWidth(int width) const;
- static const bool c_defShowName;
- static const bool c_defShowNumber;
- static const bool c_defShowBackground;
- static const bool c_defShowWindows;
- static const bool c_defWindowDragging;
enum WindowDrawMode { Plain=0, Icon=1, Pixmap=2 };
enum WindowTransparentMode { NoWindows=0, MaximizedWindows=1, AllWindows=2};
- static const WindowDrawMode c_defWindowDrawMode;
- static const WindowTransparentMode c_defWindowTransparentMode;
virtual int deskX() const { return 0; }
virtual int deskY() const { return 0; }
--- trunk/extragear/utils/kpager/kpager.cpp #1210529:1210530
@@ -64,6 +64,7 @@
#include <assert.h>
#include "kpageradaptor.h"
+#include <settings.h>
#include <QtDBus/QtDBus>
KPagerMainWindow::KPagerMainWindow(QWidget *parent, const char *name)
@@ -76,7 +77,7 @@
m_pPager = new KPager(this, 0);
setCentralWidget(m_pPager);
- KConfigGroup cfg(KGlobal::config(), "KPager");
+ KConfigGroup cfg(Settings::self()->config(), "KPager");
// Update the last used geometry
int w = cfg.readEntry(m_pPager->lWidth(),-1);
@@ -132,9 +133,8 @@
bool KPagerMainWindow::queryClose()
{
- KConfigGroup cfg = KGlobal::config()->group("KPager");
+ KConfigGroup cfg = Settings::self()->config()->group("KPager");
- cfg.writeEntry("layoutType", static_cast<int>(m_pPager->m_layoutType));
cfg.writeEntry(m_pPager->lWidth(),width());
cfg.writeEntry(m_pPager->lHeight(),height());
cfg.writeEntry("xPos",x());
@@ -206,8 +206,6 @@
m_grabWinTimer->setSingleShot(true);
connect(m_grabWinTimer, SIGNAL(timeout()), this, SLOT(slotGrabWindows()));
- KPagerConfigDialog::initConfiguration();
-
int numberOfDesktops=KWindowSystem::numberOfDesktops();
for (int i=0;i<numberOfDesktops;i++)
{
@@ -215,7 +213,7 @@
m_desktops.append(dsk);
}
- m_layoutType=static_cast<enum KPager::LayoutTypes>( \
KPagerConfigDialog::m_layoutType ); + m_layoutType = static_cast<enum \
KPager::LayoutTypes>(Settings::layoutType());
connect( KWindowSystem::self(), SIGNAL( activeWindowChanged(WId)),
SLOT(slotActiveWindowChanged(WId)));
@@ -234,10 +232,7 @@
connect( KWindowSystem::self(), SIGNAL( currentDesktopChanged(int)),
SLOT( slotCurrentDesktopChanged(int) ) );
- QFont defFont(KGlobalSettings::generalFont().family(), 10, QFont::Bold);
- KConfigGroup cfg(KGlobal::config(), "KPager");
- defFont = cfg.readEntry("Font", defFont);
- setFont(defFont);
+ setFont(Settings::font());
m_prefs_action = parent->actionCollection()->addAction( \
KStandardAction::Preferences, this, SLOT(configureDialog()) );
m_quit_action = parent->actionCollection()->addAction( KStandardAction::Quit, \
qApp, SLOT(quit()) ); @@ -370,21 +365,14 @@
KPagerConfigDialog *dialog= new KPagerConfigDialog(this);
if (dialog->exec())
{
- m_layoutType=static_cast<enum \
KPager::LayoutTypes>(KPagerConfigDialog::m_layoutType);
- KConfigGroup cfg = KGlobal::config()->group("KPager");
+ m_layoutType = static_cast<enum \
KPager::LayoutTypes>(Settings::layoutType()); + KConfigGroup cfg = \
Settings::self()->config()->group("KPager"); int nWd = (parent() ? ((QWidget \
*)parent())->width() : width()); int nHg = (parent() ? ((QWidget \
*)parent())->width() : width());
cfg.writeEntry(lWidth(),nWd);
cfg.writeEntry(lHeight(),nHg);
- cfg.writeEntry("windowDrawMode",KPagerConfigDialog::m_windowDrawMode);
- cfg.writeEntry("layoutType",KPagerConfigDialog::m_layoutType);
- cfg.writeEntry("showNumber",KPagerConfigDialog::m_showNumber);
- cfg.writeEntry("showName",KPagerConfigDialog::m_showName);
- cfg.writeEntry("showWindows",KPagerConfigDialog::m_showWindows);
- cfg.writeEntry("showBackground",KPagerConfigDialog::m_showBackground);
- cfg.writeEntry("windowDragging",KPagerConfigDialog::m_windowDragging);
updateLayout();
for( QList <Desktop *>::Iterator it = m_desktops.begin(); it != \
m_desktops.end(); ++it ) @@ -570,7 +558,7 @@
if (m_grabWinTimer->isActive()) m_grabWinTimer->stop();
- if ( static_cast<Desktop::WindowDrawMode>( KPagerConfigDialog::m_windowDrawMode \
) == Desktop::Pixmap ) + if ( \
static_cast<Desktop::WindowDrawMode>(Settings::windowDrawMode()) == Desktop::Pixmap ) \
m_grabWinTimer->start(1000); }
@@ -691,6 +679,4 @@
return QSize(w,h);
}
-const KPager::LayoutTypes KPager::c_defLayout=KPager::Horizontal;
-
#include "kpager.moc"
--- trunk/extragear/utils/kpager/kpager.h #1210529:1210530
@@ -137,9 +137,6 @@
QTimer *m_grabWinTimer;
int m_currentDesktop;
-
-public:
- static const LayoutTypes c_defLayout;
};
#endif
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic