mirror of
https://github.com/KDE/latte-dock.git
synced 2024-12-24 05:33:50 +03:00
update commandline options
This commit is contained in:
parent
2b4bbd20f2
commit
fbf5808667
@ -42,9 +42,8 @@
|
||||
|
||||
namespace Latte {
|
||||
|
||||
DockCorona::DockCorona(QStringList debugFlags, QObject *parent)
|
||||
DockCorona::DockCorona(QObject *parent)
|
||||
: Plasma::Corona(parent),
|
||||
m_debugFlags(debugFlags),
|
||||
m_activityConsumer(new KActivities::Consumer(this))
|
||||
{
|
||||
KPackage::Package package(new DockPackage(this));
|
||||
@ -255,11 +254,6 @@ void DockCorona::closeApplication()
|
||||
qGuiApp->quit();
|
||||
}
|
||||
|
||||
QStringList DockCorona::debugFlags() const
|
||||
{
|
||||
return m_debugFlags;
|
||||
}
|
||||
|
||||
void DockCorona::aboutApplication()
|
||||
{
|
||||
if (aboutDialog) {
|
||||
|
@ -44,7 +44,7 @@ class DockCorona : public Plasma::Corona {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
DockCorona(QStringList debugFlags = QStringList(), QObject *parent = nullptr);
|
||||
DockCorona(QObject *parent = nullptr);
|
||||
virtual ~DockCorona();
|
||||
|
||||
int numScreens() const override;
|
||||
@ -54,8 +54,6 @@ public:
|
||||
|
||||
QList<Plasma::Types::Location> freeEdges(int screen) const;
|
||||
|
||||
QStringList debugFlags() const;
|
||||
|
||||
int docksCount(int screen) const;
|
||||
int screenForContainment(const Plasma::Containment *containment) const override;
|
||||
|
||||
@ -88,8 +86,6 @@ private:
|
||||
|
||||
bool m_activitiesStarting{true};
|
||||
|
||||
QStringList m_debugFlags;
|
||||
|
||||
QHash<const Plasma::Containment *, DockView *> m_dockViews;
|
||||
QHash<const Plasma::Containment *, DockView *> m_waitingDockViews;
|
||||
QList<KDeclarative::QmlObject *> m_alternativesObjects;
|
||||
|
@ -552,9 +552,9 @@ QStringList DockView::debugFlags() const
|
||||
DockCorona *dockCorona = qobject_cast<DockCorona *>(this->corona());
|
||||
|
||||
if (dockCorona)
|
||||
return dockCorona->debugFlags();
|
||||
return qGuiApp->arguments();
|
||||
|
||||
return QStringList();
|
||||
return {};
|
||||
}
|
||||
|
||||
bool DockView::tasksPresent()
|
||||
@ -578,6 +578,11 @@ bool DockView::event(QEvent *e)
|
||||
{
|
||||
emit eventTriggered(e);
|
||||
|
||||
if (e->type() == QEvent::Leave) {
|
||||
engine()->collectGarbage();
|
||||
engine()->clearComponentCache();
|
||||
engine()->trimComponentCache();
|
||||
}
|
||||
return ContainmentView::event(e);
|
||||
}
|
||||
|
||||
|
103
app/main.cpp
103
app/main.cpp
@ -22,6 +22,7 @@
|
||||
#include "config-latte.h"
|
||||
|
||||
#include <memory>
|
||||
#include <csignal>
|
||||
|
||||
#include <QApplication>
|
||||
#include <QDebug>
|
||||
@ -36,6 +37,7 @@
|
||||
#include <KLocalizedString>
|
||||
#include <KAboutData>
|
||||
|
||||
|
||||
//! COLORS
|
||||
#define CNORMAL "\e[0m"
|
||||
#define CIGREEN "\e[1;32m"
|
||||
@ -46,25 +48,10 @@
|
||||
#define CRED "\e[0;31m"
|
||||
|
||||
inline void configureAboutData();
|
||||
|
||||
void noMessageOutput(QtMsgType type, const QMessageLogContext &context, const QString &msg)
|
||||
{
|
||||
Q_UNUSED(type);
|
||||
Q_UNUSED(context);
|
||||
Q_UNUSED(msg);
|
||||
}
|
||||
inline void commandLineOptions();
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
QString tmpDir = QDir::tempPath();
|
||||
QLockFile lockFile(tmpDir + "/latte-dock.lock");
|
||||
|
||||
if (!lockFile.tryLock(100)) {
|
||||
qDebug() << i18n("Warning: An instance of Latte application is already running!!!");
|
||||
exit(0);
|
||||
}
|
||||
|
||||
// Devive pixel ratio has some problems in latte (plasmashell) currently.
|
||||
{ // Devive pixel ratio has some problems in latte (plasmashell) currently.
|
||||
// - dialog continually expands (347951)
|
||||
// - Text element text is screwed (QTBUG-42606)
|
||||
// - Panel struts (350614)
|
||||
@ -76,39 +63,65 @@ int main(int argc, char **argv)
|
||||
QApplication app(argc, argv);
|
||||
KLocalizedString::setApplicationDomain("latte-dock");
|
||||
app.setWindowIcon(QIcon::fromTheme(QStringLiteral("latte-dock")));
|
||||
|
||||
configureAboutData();
|
||||
|
||||
//! set pattern for debug messages
|
||||
//! [%{type}] [%{function}:%{line}] - %{message} [%{backtrace}]
|
||||
qSetMessagePattern(QStringLiteral(
|
||||
CIGREEN "[%{type} " CGREEN "%{time h:mm:ss.zz}" CIGREEN "]" CNORMAL
|
||||
#ifndef QT_NO_DEBUG
|
||||
CIRED " [" CCYAN "%{function}" CIRED ":" CCYAN "%{line}" CIRED "]"
|
||||
#endif
|
||||
CICYAN " - " CNORMAL "%{message}"
|
||||
CIRED "%{if-fatal}\n%{backtrace depth=8 separator=\"\n\"}%{endif}"
|
||||
"%{if-critical}\n%{backtrace depth=8 separator=\"\n\"}%{endif}" CNORMAL));
|
||||
QCommandLineParser parser;
|
||||
parser.addHelpOption();
|
||||
parser.addVersionOption();
|
||||
parser.addOptions({
|
||||
{{"r", "replace"}, i18nc("command line", "Replace the current dock instance")}
|
||||
, {{"d", "debug"}, i18nc("command line", "Show the debugging messages on stdout")}
|
||||
, {"mask", i18nc("command line" , "Show messages of debugging for the mask (Only useful to devs)")}
|
||||
, {"graphics", i18nc("command line", "Draw boxes around of the applets")}
|
||||
, {"with-window", i18nc("command line", "Open a window with much debug information")}
|
||||
});
|
||||
|
||||
// qputenv("QT_QUICK_CONTROLS_1_STYLE", "Desktop");
|
||||
QStringList debugFlags;
|
||||
parser.process(app);
|
||||
|
||||
if (!app.arguments().contains(QLatin1String("--debug"))) {
|
||||
qInstallMessageHandler(noMessageOutput);
|
||||
} else {
|
||||
if (app.arguments().contains(QLatin1String("--with-window"))) {
|
||||
debugFlags.append("--with-window");
|
||||
}
|
||||
QLockFile lockFile {QDir::tempPath() + "/latte-dock.lock"};
|
||||
|
||||
if (app.arguments().contains(QLatin1String("--graphics"))) {
|
||||
debugFlags.append("--graphics");
|
||||
}
|
||||
|
||||
if (app.arguments().contains(QLatin1String("--mask"))) {
|
||||
debugFlags.append("--mask");
|
||||
int timeout {100};
|
||||
if (parser.isSet(QStringLiteral("replace"))) {
|
||||
qint64 pid{-1};
|
||||
if (lockFile.getLockInfo(&pid, nullptr, nullptr)) {
|
||||
kill(static_cast<__pid_t>(pid), SIGINT);
|
||||
timeout = 3000;
|
||||
}
|
||||
}
|
||||
|
||||
Latte::DockCorona corona(debugFlags);
|
||||
if (!lockFile.tryLock(timeout)) {
|
||||
qInfo() << i18n("An instance is already running!, use --replace to restart Latte");
|
||||
qGuiApp->exit();
|
||||
}
|
||||
|
||||
if (parser.isSet(QStringLiteral("d")) || parser.isSet(QStringLiteral("m"))) {
|
||||
//! set pattern for debug messages
|
||||
//! [%{type}] [%{function}:%{line}] - %{message} [%{backtrace}]
|
||||
|
||||
qSetMessagePattern(QStringLiteral(
|
||||
CIGREEN "[%{type} " CGREEN "%{time h:mm:ss.zz}" CIGREEN "]" CNORMAL
|
||||
#ifndef QT_NO_DEBUG
|
||||
CIRED " [" CCYAN "%{function}" CIRED ":" CCYAN "%{line}" CIRED "]"
|
||||
#endif
|
||||
CICYAN " - " CNORMAL "%{message}"
|
||||
CIRED "%{if-fatal}\n%{backtrace depth=8 separator=\"\n\"}%{endif}"
|
||||
"%{if-critical}\n%{backtrace depth=8 separator=\"\n\"}%{endif}" CNORMAL));
|
||||
} else {
|
||||
const auto noMessageOutput = [](QtMsgType, const QMessageLogContext&, const QString&){};
|
||||
qInstallMessageHandler(noMessageOutput);
|
||||
}
|
||||
|
||||
// qputenv("QT_QUICK_CONTROLS_1_STYLE", "Desktop");
|
||||
|
||||
auto signal_handler = [](int) {
|
||||
qGuiApp->exit();
|
||||
};
|
||||
|
||||
std::signal(SIGKILL, signal_handler);
|
||||
std::signal(SIGINT, signal_handler);
|
||||
|
||||
Latte::DockCorona corona;
|
||||
return app.exec();
|
||||
}
|
||||
|
||||
@ -146,3 +159,9 @@ inline void configureAboutData()
|
||||
|
||||
KAboutData::setApplicationData(about);
|
||||
}
|
||||
|
||||
inline void commandLineOptions()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user