mirror of
https://bitbucket.org/smil3y/kde-extraapps.git
synced 2025-02-23 18:32:53 +00:00
generic: misc cleanups
This commit is contained in:
parent
7c95601a4e
commit
bad27e353b
3 changed files with 53 additions and 72 deletions
|
@ -24,11 +24,8 @@
|
|||
#include <KToggleAction>
|
||||
#include <KToggleAction>
|
||||
#include <KLocalizedString>
|
||||
#include <KIcon>
|
||||
#include <KIconLoader>
|
||||
#include <KCmdLineArgs>
|
||||
#include <KHelpMenu>
|
||||
#include <KMenu>
|
||||
#include <KFontDialog>
|
||||
#include <KUniqueApplication>
|
||||
|
||||
|
@ -50,9 +47,6 @@ KbdTray::~KbdTray()
|
|||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
QMenu* KbdTray::getContextMenu()
|
||||
{
|
||||
return this->contextMenu();
|
||||
|
|
|
@ -72,8 +72,6 @@ KvkbdApp::KvkbdApp(bool loginhelper) : KUniqueApplication(), is_login(loginhelpe
|
|||
|
||||
KConfigGroup cfg = KGlobal::config()->group("");
|
||||
|
||||
|
||||
|
||||
if (!is_login) {
|
||||
widget->setAttribute(Qt::WA_ShowWithoutActivating);
|
||||
widget->setAttribute(Qt::WA_DeleteOnClose, false);
|
||||
|
@ -149,8 +147,7 @@ KvkbdApp::KvkbdApp(bool loginhelper) : KUniqueApplication(), is_login(loginhelpe
|
|||
cmenu->addAction(stickyModKeysAction);
|
||||
connect(stickyModKeysAction,SIGNAL(triggered(bool)), this, SLOT(setStickyModKeys(bool)));
|
||||
widget->setProperty("stickyModKeys", stickyModKeys);
|
||||
|
||||
|
||||
|
||||
QFont font = cfg.readEntry("font", widget->font());
|
||||
widget->setFont(font);
|
||||
|
||||
|
@ -190,50 +187,44 @@ KvkbdApp::KvkbdApp(bool loginhelper) : KUniqueApplication(), is_login(loginhelpe
|
|||
pos.setY(pos.y()-dock->height());
|
||||
|
||||
QRect dockGeometry(pos, dock->size());
|
||||
|
||||
|
||||
QRect c_dock_geometry = cfg.readEntry("dockGeometry", dockGeometry);
|
||||
if (!screenGeometry.contains(c_dock_geometry, true)) {
|
||||
c_dock_geometry = dockGeometry;
|
||||
c_dock_geometry = dockGeometry;
|
||||
}
|
||||
dock->setGeometry(c_dock_geometry);
|
||||
|
||||
|
||||
widget->show();
|
||||
|
||||
|
||||
bool extensionVisible = cfg.readEntry("extentVisible", QVariant(true)).toBool();
|
||||
if (!extensionVisible) {
|
||||
toggleExtension();
|
||||
}
|
||||
|
||||
|
||||
|
||||
setQuitOnLastWindowClosed (is_login);
|
||||
|
||||
|
||||
connect(this, SIGNAL(aboutToQuit()), this, SLOT(storeConfig()));
|
||||
emit fontUpdated(widget->font());
|
||||
|
||||
if (dockVisible && !is_login) {
|
||||
dock->show();
|
||||
dock->show();
|
||||
}
|
||||
|
||||
|
||||
xkbd->start();
|
||||
|
||||
if (!is_login) {
|
||||
bool vis = cfg.readEntry("visible", QVariant(true)).toBool();
|
||||
if (!vis ) {
|
||||
|
||||
widget->showMinimized();
|
||||
|
||||
}
|
||||
widget->setWindowTitle("kvkbd");
|
||||
tray->show();
|
||||
}
|
||||
else {
|
||||
QTimer *timer = new QTimer(this);
|
||||
timer->setInterval(1000);
|
||||
connect(timer, SIGNAL(timeout()), widget, SLOT(raise()));
|
||||
timer->start();
|
||||
widget->setWindowTitle("kvkbd.login");
|
||||
bool vis = cfg.readEntry("visible", QVariant(true)).toBool();
|
||||
if (!vis ) {
|
||||
widget->showMinimized();
|
||||
}
|
||||
widget->setWindowTitle("kvkbd");
|
||||
tray->show();
|
||||
} else {
|
||||
QTimer *timer = new QTimer(this);
|
||||
timer->setInterval(1000);
|
||||
connect(timer, SIGNAL(timeout()), widget, SLOT(raise()));
|
||||
timer->start();
|
||||
widget->setWindowTitle("kvkbd.login");
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -246,15 +237,15 @@ KvkbdApp::~KvkbdApp()
|
|||
void KvkbdApp::storeConfig()
|
||||
{
|
||||
KConfigGroup cfg = KGlobal::config()->group("");
|
||||
|
||||
|
||||
cfg.writeEntry("visible", widget->isVisible());
|
||||
cfg.writeEntry("geometry", widget->geometry());
|
||||
cfg.writeEntry("locked", widget->isLocked());
|
||||
cfg.writeEntry("stickyModKeys", widget->property("stickyModKeys"));
|
||||
|
||||
|
||||
cfg.writeEntry("showdock", dock->isVisible());
|
||||
cfg.writeEntry("dockGeometry", dock->geometry());
|
||||
|
||||
|
||||
cfg.writeEntry("layout", widget->property("layout"));
|
||||
cfg.writeEntry("colors", widget->property("colors"));
|
||||
cfg.writeEntry("font", widget->font());
|
||||
|
@ -293,8 +284,8 @@ void KvkbdApp::chooseFont()
|
|||
|
||||
QFont widgetFont = widget->font();
|
||||
|
||||
int result = KFontDialog::getFont( widgetFont, KFontChooser::NoDisplayFlags, widget );
|
||||
if ( result == KFontDialog::Accepted ) {
|
||||
int result = KFontDialog::getFont(widgetFont, KFontChooser::NoDisplayFlags, widget);
|
||||
if (result == KFontDialog::Accepted) {
|
||||
|
||||
widget->setFont(widgetFont);
|
||||
emit fontUpdated(widgetFont);
|
||||
|
@ -358,7 +349,7 @@ void KvkbdApp::partLoaded(MainWidget *vPart, int total_rows, int total_cols)
|
|||
QObject::connect(xkbd, SIGNAL(layoutUpdated(int,QString)), vPart, SLOT(updateLayout(int,QString)));
|
||||
QObject::connect(xkbd, SIGNAL(groupStateChanged(const ModifierGroupStateMap&)), vPart, SLOT(updateGroupState(const ModifierGroupStateMap&)));
|
||||
QObject::connect(xkbd, SIGNAL(keyProcessComplete(unsigned int)), this, SLOT(keyProcessComplete(unsigned int)));
|
||||
|
||||
|
||||
QObject::connect(this, SIGNAL(textSwitch(bool)), vPart, SLOT(textSwitch(bool)));
|
||||
QObject::connect(this, SIGNAL(fontUpdated(const QFont&)), vPart, SLOT(updateFont(const QFont&)));
|
||||
|
||||
|
@ -368,7 +359,7 @@ void KvkbdApp::partLoaded(MainWidget *vPart, int total_rows, int total_cols)
|
|||
void KvkbdApp::keyProcessComplete(unsigned int)
|
||||
{
|
||||
if (widget->property("stickyModKeys").toBool()) return;
|
||||
|
||||
|
||||
QListIterator<VButton *> itr(modKeys);
|
||||
while (itr.hasNext()) {
|
||||
VButton *mod = itr.next();
|
||||
|
@ -383,8 +374,8 @@ void KvkbdApp::buttonAction(const QString &action)
|
|||
|
||||
if (QString::compare(action , "toggleVisibility")==0) {
|
||||
if (!is_login) {
|
||||
widget->toggleVisibility();
|
||||
}
|
||||
widget->toggleVisibility();
|
||||
}
|
||||
}
|
||||
else if (QString::compare(action , "toggleExtension")==0) {
|
||||
|
||||
|
|
|
@ -34,38 +34,34 @@ static const char version[] = "0.7.2";
|
|||
|
||||
void findLoginWindow()
|
||||
{
|
||||
unsigned int numkids, i, scrn;
|
||||
Window r, p;
|
||||
Window *kids=0;
|
||||
//XWindowAttributes attr;
|
||||
Window root;
|
||||
Display *dipsy=0;
|
||||
char *win_name=0;
|
||||
unsigned int numkids, i, scrn;
|
||||
Window r, p;
|
||||
Window *kids=0;
|
||||
//XWindowAttributes attr;
|
||||
Window root;
|
||||
Display *dipsy=0;
|
||||
char *win_name=0;
|
||||
|
||||
dipsy = XOpenDisplay(0);
|
||||
if (!dipsy)return;
|
||||
dipsy = XOpenDisplay(0);
|
||||
if (!dipsy) return;
|
||||
|
||||
scrn = DefaultScreen(dipsy);
|
||||
root = RootWindow(dipsy, scrn);
|
||||
|
||||
XQueryTree(dipsy, root, &r, &p, &kids, &numkids);
|
||||
|
||||
scrn = DefaultScreen(dipsy);
|
||||
root = RootWindow(dipsy, scrn);
|
||||
|
||||
for (i = 0; i < numkids; ++i)
|
||||
{
|
||||
XFetchName(dipsy, kids[i], &win_name);
|
||||
QString c(win_name);
|
||||
|
||||
if (c=="kvkbd.login")
|
||||
{
|
||||
long wid = kids[i];
|
||||
XDestroyWindow(dipsy,wid);
|
||||
XFlush(dipsy);
|
||||
i=numkids;
|
||||
}
|
||||
XFree(win_name);
|
||||
}
|
||||
XCloseDisplay(dipsy);
|
||||
XQueryTree(dipsy, root, &r, &p, &kids, &numkids);
|
||||
|
||||
for (i = 0; i < numkids; ++i) {
|
||||
XFetchName(dipsy, kids[i], &win_name);
|
||||
QString c(win_name);
|
||||
if (c=="kvkbd.login") {
|
||||
long wid = kids[i];
|
||||
XDestroyWindow(dipsy,wid);
|
||||
XFlush(dipsy);
|
||||
i=numkids;
|
||||
}
|
||||
XFree(win_name);
|
||||
}
|
||||
XCloseDisplay(dipsy);
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
|
|
Loading…
Add table
Reference in a new issue