List: licq-devel
Subject: [Licq-devel] Some GUI patches
From: Jörg_Mensmann <joerg_ml () bitplanet ! de>
Date: 2011-11-13 18:24:46
Message-ID: m3hb27op75.fsf () msgid ! bitplanet ! de
[Download RAW message or body]
Hi,
here is bunch of patches for the Qt4-GUI that fix session handling and
global shortcuts on KDE and make the display of remote user time less
intrusive.
ciao
J=F6rg
[Attachment #3 (text/x-patch)]
>From e096c0f979863f911097cc380f06389da6332e14 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jörg Mensmann?= <joerg_ml@bitplanet.de>
Subject: [PATCH 1/3] kde4-gui: Fix command line handling for plugin.
The plugin would interpret a "-session" argument as a request to set
the skin (-s). When restored by the session manager, it would
therefore try to load a non-existent skin file and fall back to the
default one, ignoring the skin selected by the user.
In addition, there is a workaround for handling "licq -- --help" and
argument parse errors gracefully. Since KCmdLineArgs::parsedArgs()
calls exit() directly in these cases, the Licq daemon would not be
shut down and the application would hang. The workaround installs an
atexit-handler that shuts down the daemon before calling parsedArgs().
---
qt4-gui/src/core/licqgui.cpp | 32 +++++++++++++++++++++++++++++---
qt4-gui/src/core/plugin.cpp | 42 ++++++++++++++++++++++++++++++++++++++----
2 files changed, 67 insertions(+), 7 deletions(-)
diff --git a/qt4-gui/src/core/licqgui.cpp b/qt4-gui/src/core/licqgui.cpp
index 5ee6f72..8fa32c0 100644
--- a/qt4-gui/src/core/licqgui.cpp
+++ b/qt4-gui/src/core/licqgui.cpp
@@ -41,11 +41,12 @@
#include <QUrl>
#ifdef USE_KDE
+#include <KDE/KCmdLineArgs>
#include <KDE/KStandardDirs>
#include <KDE/KToolInvocation>
#include <KDE/KUrl>
#else
-# include <QDesktopServices>
+#include <QDesktopServices>
#endif
#if defined(Q_WS_X11)
@@ -179,10 +180,30 @@ LicqGui::LicqGui(int& argc, char** argv) :
// parse command line for arguments
#ifdef USE_KDE
- while ((i = getopt(argc, argv, "hs:i:e:dD")) > 0)
+ KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
+
+ if (args->isSet("s")) // skin name
+ mySkin = args->getOption("s");
+
+ if (args->isSet("i")) // icons name
+ myIcons = args->getOption("i");
+
+ if (args->isSet("e")) // extended icons name
+ myExtendedIcons = args->getOption("e");
+
+ if (args->isSet("d")) // dock icon
+ {
+ if (!myDisableDockIcon)
+ myStartHidden = true;
+ }
+
+ if (args->isSet("D")) // disable dock icon
+ {
+ myStartHidden = false; // discard any -d
+ myDisableDockIcon = true;
+ }
#else
while ((i = getopt(argc, argv, "hs:i:e:g:dD")) > 0)
-#endif
{
switch (i)
{
@@ -208,6 +229,7 @@ LicqGui::LicqGui(int& argc, char** argv) :
myDisableDockIcon = true;
}
}
+#endif
// Since Licq daemon blocks SIGCHLD and Qt never receives it,
// QProcess hangs. By this we avoid Qt's attempts to be
@@ -489,7 +511,11 @@ void LicqGui::commitData(QSessionManager& sm)
QStringList restartCmd;
restartCmd = myCmdLineParams;
+#ifdef USE_KDE
+ restartCmd += QString("--session");
+#else
restartCmd += QString("-session");
+#endif
restartCmd += sm.sessionId();
sm.setRestartCommand(restartCmd);
}
diff --git a/qt4-gui/src/core/plugin.cpp b/qt4-gui/src/core/plugin.cpp
index ae4183a..c19b97a 100644
--- a/qt4-gui/src/core/plugin.cpp
+++ b/qt4-gui/src/core/plugin.cpp
@@ -88,7 +88,7 @@ std::string QtGuiPlugin::usage() const
" -e : set the extended icons to use (must be in %2%3%6)"
)
.arg(PLUGIN_NAME)
- .arg(Licq::gDaemon.baseDir().c_str())
+ .arg(Licq::gDaemon.baseDir().c_str())
.arg(QTGUI_DIR)
.arg(SKINS_DIR)
.arg(ICONS_DIR)
@@ -127,15 +127,49 @@ bool QtGuiPlugin::init(int argc, char** argv)
return true;
}
+#ifdef USE_KDE
+
+namespace {
+
+bool shutdownDaemonOnExit = false;
+
+void shutdownDaemon()
+{
+ if (shutdownDaemonOnExit)
+ {
+ Licq::gDaemon.Shutdown();
+ sleep(1); // Give it some time
+ }
+}
+
+} // namespace
+
+#endif // USE_KDE
+
int QtGuiPlugin::run()
{
#ifdef USE_KDE
// Don't use the KDE crash handler (drkonqi).
setenv("KDE_DEBUG", "true", 0);
- KCmdLineArgs::init(myArgc, myArgv,
- "licq", "qt4-gui",
- ki18n(DISPLAY_PLUGIN_NAME), PLUGIN_VERSION_STRING);
+ KCmdLineArgs::init(myArgc, myArgv, "licq", "qt4-gui",
+ ki18n(DISPLAY_PLUGIN_NAME), PLUGIN_VERSION_STRING);
+
+ // Duplicating options from LicqGui::LicqGui
+ KCmdLineOptions options;
+ options.add("h", ki18n("help screen"));
+ options.add("d", ki18n("start hidden (dock icon only)"));
+ options.add("D", ki18n("disable dock icon for this session (does not affect dock icon settings)"));
+ options.add("s <skinname>", ki18n("set the skin to use"));
+ options.add("i <iconpack>", ki18n("set the icons to use"));
+ options.add("e <extendediconpack>", ki18n("set the extended icons to use"));
+ KCmdLineArgs::addCmdLineOptions(options);
+
+ atexit(shutdownDaemon);
+ shutdownDaemonOnExit = true;
+ // This will call exit() for --help or on parse error.
+ KCmdLineArgs::parsedArgs();
+ shutdownDaemonOnExit = false;
#endif
LicqQtGui::LicqGui* licqQtGui = new LicqQtGui::LicqGui(myArgc, myArgv);
--
1.7.6.4
[Attachment #4 (text/x-patch)]
> From 71d60db7cab5f1b62439d964f9d2c340cab700aa Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jörg Mensmann?= <joerg_ml@bitplanet.de>
Subject: [PATCH 2/3] kde4-gui: Use KDE mechanism for global shortcuts, since
Qt's doesn't work.
---
qt4-gui/src/core/licqgui.cpp | 16 ++++++++--------
qt4-gui/src/core/licqgui.h | 8 ++++----
qt4-gui/src/core/mainwin.cpp | 23 +++++++++++++++++++++++
qt4-gui/src/core/mainwin.h | 6 ++++++
4 files changed, 41 insertions(+), 12 deletions(-)
diff --git a/qt4-gui/src/core/licqgui.cpp b/qt4-gui/src/core/licqgui.cpp
index 8fa32c0..9b7f433 100644
--- a/qt4-gui/src/core/licqgui.cpp
+++ b/qt4-gui/src/core/licqgui.cpp
@@ -42,6 +42,7 @@
#ifdef USE_KDE
#include <KDE/KCmdLineArgs>
+#include <KDE/KGlobalAccel>
#include <KDE/KStandardDirs>
#include <KDE/KToolInvocation>
#include <KDE/KUrl>
@@ -161,9 +162,12 @@ LicqGui::LicqGui(int& argc, char** argv) :
#endif
myStartHidden(false),
myDisableDockIcon(false),
- myUserEventTabDlg(NULL),
+ myUserEventTabDlg(NULL)
+#if defined(Q_WS_X11) && !defined(USE_KDE)
+ ,
myPopupMessageKey(0),
myShowMainwinKey(0)
+#endif
{
assert(gLicqGui == NULL);
gLicqGui = this;
@@ -432,7 +436,7 @@ int LicqGui::Run()
Config::Chat::createInstance(this);
Config::Shortcuts::createInstance(this);
-#ifdef Q_WS_X11
+#if defined(Q_WS_X11) && !defined(USE_KDE)
connect(Config::Shortcuts::instance(), SIGNAL(shortcutsChanged()),
SLOT(updateGlobalShortcuts()));
#endif
@@ -525,7 +529,7 @@ void LicqGui::saveState(QSessionManager& sm)
sm.setRestartHint(QSessionManager::RestartIfRunning);
}
-#if defined(Q_WS_X11)
+#if defined(Q_WS_X11) && !defined(USE_KDE)
bool LicqGui::x11EventFilter(XEvent* event)
{
if (event->type == KeyPress && (myPopupMessageKey != 0 || myShowMainwinKey != 0))
@@ -548,11 +552,7 @@ bool LicqGui::x11EventFilter(XEvent* event)
XSync(dsp, false);
}
}
-#ifdef USE_KDE
- return KApplication::x11EventFilter(event);
-#else
return QApplication::x11EventFilter(event);
-#endif
}
void LicqGui::updateGlobalShortcuts()
@@ -589,7 +589,7 @@ void LicqGui::updateGlobalShortcuts()
myPopupMessageKey = newPopup;
myShowMainwinKey = newMainwin;
}
-#endif /* defined(Q_WS_X11) */
+#endif /* defined(Q_WS_X11) && !defined(USE_KDE) */
void LicqGui::changeStatus(unsigned status, bool invisible, const QString& \
autoMessage) {
diff --git a/qt4-gui/src/core/licqgui.h b/qt4-gui/src/core/licqgui.h
index 1213147..58f736a 100644
--- a/qt4-gui/src/core/licqgui.h
+++ b/qt4-gui/src/core/licqgui.h
@@ -83,9 +83,9 @@ public:
virtual void commitData(QSessionManager& sm);
virtual void saveState(QSessionManager& sm);
-#if defined(Q_WS_X11)
+#if defined(Q_WS_X11) && !defined(USE_KDE)
virtual bool x11EventFilter(XEvent* event);
-#endif /* defined(Q_WS_X11) */
+#endif /* defined(Q_WS_X11) && !defined(USE_KDE) */
/**
* Remove a contact from the list
@@ -239,7 +239,7 @@ signals:
void eventSent(const Licq::Event* event);
private slots:
-#ifdef Q_WS_X11
+#if defined(Q_WS_X11) && !defined(USE_KDE)
void updateGlobalShortcuts();
#endif
@@ -342,7 +342,7 @@ private:
UserDlgList myUserDlgList;
UserSendEventList myUserSendList;
-#ifdef Q_WS_X11
+#if defined(Q_WS_X11) && !defined(USE_KDE)
int myPopupMessageKey;
int myShowMainwinKey;
#endif
diff --git a/qt4-gui/src/core/mainwin.cpp b/qt4-gui/src/core/mainwin.cpp
index c46d2f0..6c9e958 100644
--- a/qt4-gui/src/core/mainwin.cpp
+++ b/qt4-gui/src/core/mainwin.cpp
@@ -189,6 +189,17 @@ MainWindow::MainWindow(bool bStartHidden, QWidget* parent)
shortcut = new QShortcut(Qt::Key_Delete, this);
connect(shortcut, SIGNAL(activated()), SLOT(removeUserFromGroup()));
+#ifdef USE_KDE
+ myShowMainwinGlobalAction = new KAction(this);
+ myShowMainwinGlobalAction->setObjectName("LicqShowMainWin");
+ connect(myShowMainwinGlobalAction, SIGNAL(triggered()), SLOT(trayIconClicked()));
+
+ myPopupMessageGlobalAction = new KAction(this);
+ myPopupMessageGlobalAction->setObjectName("LicqPopupMessageGlobalAction");
+ connect(myPopupMessageGlobalAction, SIGNAL(triggered()),
+ gLicqGui, SLOT(showNextEvent()));
+#endif
+
updateShortcuts();
connect(Config::Shortcuts::instance(), SIGNAL(shortcutsChanged()), \
SLOT(updateShortcuts()));
@@ -343,6 +354,18 @@ void MainWindow::updateShortcuts()
mySendChatRequestAction->setShortcut(shortcuts->getShortcut(Config::Shortcuts::MainwinUserSendChatRequest));
myCheckUserArAction->setShortcut(shortcuts->getShortcut(Config::Shortcuts::MainwinUserCheckAutoresponse));
myViewHistoryAction->setShortcut(shortcuts->getShortcut(Config::Shortcuts::MainwinUserViewHistory));
+
+#ifdef USE_KDE
+ myShowMainwinGlobalAction->setGlobalShortcut(
+ KShortcut(shortcuts->getShortcut(Config::Shortcuts::GlobalShowMainwin)),
+ KAction::ActiveShortcut | KAction::DefaultShortcut,
+ KAction::NoAutoloading);
+
+ myPopupMessageGlobalAction->setGlobalShortcut(
+ KShortcut(shortcuts->getShortcut(Config::Shortcuts::GlobalPopupMessage)),
+ KAction::ActiveShortcut | KAction::DefaultShortcut,
+ KAction::NoAutoloading);
+#endif
}
void MainWindow::trayIconClicked()
diff --git a/qt4-gui/src/core/mainwin.h b/qt4-gui/src/core/mainwin.h
index 5ccf852..69da68b 100644
--- a/qt4-gui/src/core/mainwin.h
+++ b/qt4-gui/src/core/mainwin.h
@@ -23,6 +23,7 @@
#include "config.h"
#ifdef USE_KDE
+# include <KDE/KAction>
# include <KDE/KMenuBar>
#else
# include <QMenuBar>
@@ -132,6 +133,11 @@ private:
QAction* myCheckUserArAction;
QAction* myViewHistoryAction;
+#ifdef USE_KDE
+ KAction* myPopupMessageGlobalAction;
+ KAction* myShowMainwinGlobalAction;
+#endif
+
// Widgets
UserView* myUserView;
#ifdef USE_KDE
--
1.7.6.4
[Attachment #5 (text/x-patch)]
>From 0657f4901310776ea379f3eca02a32fcd8a6dcca Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jörg Mensmann?= <joerg_ml@bitplanet.de>
Subject: [PATCH 3/3] qt4-gui: Show remote user time only when it differs from
the local time.
- When remote user time is unknown, also just hide the time widget
- Do not show seconds, as they clutter the display
- Update time every second instead of every 3 seconds
---
qt4-gui/src/userevents/usereventcommon.cpp | 16 +++++++---------
1 files changed, 7 insertions(+), 9 deletions(-)
diff --git a/qt4-gui/src/userevents/usereventcommon.cpp b/qt4-gui/src/userevents/usereventcommon.cpp
index 543e337..ac3b9ed 100644
--- a/qt4-gui/src/userevents/usereventcommon.cpp
+++ b/qt4-gui/src/userevents/usereventcommon.cpp
@@ -106,10 +106,7 @@ UserEventCommon::UserEventCommon(const Licq::UserId& userId, QWidget* parent, co
myTimezone = new InfoField(true);
myTimezone->setToolTip(tr("User's current local time"));
- int timezoneWidth - qMax(myTimezone->fontMetrics().width("88:88:88"),
- myTimezone->fontMetrics().width(tr("Unknown")))
- + 10;
+ int timezoneWidth = myTimezone->fontMetrics().width("88:88") + 10;
myTimezone->setFixedWidth(timezoneWidth);
myTimezone->setAlignment(Qt::AlignCenter);
myTimezone->setFocusPolicy(Qt::ClickFocus);
@@ -291,19 +288,20 @@ void UserEventCommon::flashTaskbar()
void UserEventCommon::updateWidgetInfo(const Licq::User* u)
{
const QTextCodec* codec = UserCodec::codecForUser(u);
+ myRemoteTimeOffset = u->LocalTimeOffset();
- if (u->GetTimezone() == Licq::User::TimezoneUnknown)
- myTimezone->setText(tr("Unknown"));
+ if (u->GetTimezone() == Licq::User::TimezoneUnknown || myRemoteTimeOffset == 0)
+ myTimezone->setVisible(false);
else
{
- myRemoteTimeOffset = u->LocalTimeOffset();
+ myTimezone->setVisible(true);
updateTime();
if (myTimeTimer == NULL)
{
myTimeTimer = new QTimer(this);
connect(myTimeTimer, SIGNAL(timeout()), SLOT(updateTime()));
- myTimeTimer->start(3000);
+ myTimeTimer->start(1000);
}
}
@@ -414,7 +412,7 @@ void UserEventCommon::updateTime()
{
QDateTime t;
t.setTime_t(time(NULL) + myRemoteTimeOffset);
- myTimezone->setText(t.time().toString());
+ myTimezone->setText(t.time().toString("hh:mm"));
}
void UserEventCommon::updateTyping()
--
1.7.6.4
------------------------------------------------------------------------------
RSA(R) Conference 2012
Save $700 by Nov 18
Register now
http://p.sf.net/sfu/rsa-sfdev2dev1
_______________________________________________
Licq-devel mailing list
Licq-devel@licq.org
https://lists.sourceforge.net/lists/listinfo/licq-devel
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic