Remove -c switch.

This commit is contained in:
Martin Rotter 2016-08-22 08:24:31 +02:00
parent 9eb2731093
commit 32151644a3
3 changed files with 48 additions and 71 deletions

View File

@ -40,8 +40,6 @@
int main(int argc, char *argv[]) {
bool run_minimal_without_gui = false;
for (int i = 0; i < argc; i++) {
const QString str = QString::fromLocal8Bit(argv[i]);
@ -49,20 +47,10 @@ int main(int argc, char *argv[]) {
qDebug("Usage: rssguard [OPTIONS]\n\n"
"Option\t\tMeaning\n"
"-h\t\tDisplays this help.\n"
"-q\t\tQuits minimal non-GUI instance of application already running on this machine.\n"
"-c\t\tStarts the application without GUI and will regularly update configured feeds.\n\n"
"Running with '-c' option starts application without GUI and/or tray icon. No "
"message boxes will be shown, no GUI. Only minimal functionality will be enabled, including periodic checking for "
"feed/message updates. Note that you must configure the application via GUI first! So to really get periodic "
"feed updates, you must import some feeds and set their auto-update policy first in the GUI.\n\n"
"You can quick the minimal non-GUI application instance either by just killing it or by running the application "
"executable again with -q option.");
"-q\t\tQuits minimal non-GUI instance of application already running on this machine.");
return EXIT_SUCCESS;
}
else if (str == "-c") {
run_minimal_without_gui = true;
}
}
//: Abbreviation of language, e.g. en.
@ -79,7 +67,7 @@ int main(int argc, char *argv[]) {
qInstallMessageHandler(Debugging::debugHandler);
// Instantiate base application object.
Application application(APP_LOW_NAME, run_minimal_without_gui, argc, argv);
Application application(APP_LOW_NAME, argc, argv);
qDebug("Instantiated Application class.");
// Check if another instance is running.
@ -96,14 +84,12 @@ int main(int argc, char *argv[]) {
// Add an extra path for non-system icon themes and set current icon theme
// and skin.
if (!run_minimal_without_gui) {
qApp->icons()->setupSearchPaths();
qApp->icons()->loadCurrentIconTheme();
qApp->skins()->loadCurrentSkin();
qApp->icons()->setupSearchPaths();
qApp->icons()->loadCurrentIconTheme();
qApp->skins()->loadCurrentSkin();
// Load localization and setup locale before any widget is constructed.
qApp->localization()->loadActiveLanguage();
}
// Load localization and setup locale before any widget is constructed.
qApp->localization()->loadActiveLanguage();
// These settings needs to be set before any QSettings object.
Application::setApplicationName(APP_NAME);
@ -118,52 +104,47 @@ int main(int argc, char *argv[]) {
// Setup single-instance behavior.
QObject::connect(&application, &Application::messageReceived, &application, &Application::processExecutionMessage);
if (!run_minimal_without_gui) {
qDebug().nospace() << "Creating main application form in thread: \'" << QThread::currentThreadId() << "\'.";
qDebug().nospace() << "Creating main application form in thread: \'" << QThread::currentThreadId() << "\'.";
// Instantiate main application window.
FormMain main_window;
// Instantiate main application window.
FormMain main_window;
// Set correct information for main window.
main_window.setWindowTitle(APP_LONG_NAME);
// Set correct information for main window.
main_window.setWindowTitle(APP_LONG_NAME);
// Now is a good time to initialize dynamic keyboard shortcuts.
DynamicShortcuts::load(qApp->userActions());
// Now is a good time to initialize dynamic keyboard shortcuts.
DynamicShortcuts::load(qApp->userActions());
// Display main window.
if (qApp->settings()->value(GROUP(GUI), SETTING(GUI::MainWindowStartsHidden)).toBool() && SystemTrayIcon::isSystemTrayActivated()) {
qDebug("Hiding the main window when the application is starting.");
main_window.switchVisibility(true);
}
else {
qDebug("Showing the main window when the application is starting.");
main_window.show();
}
// Display tray icon if it is enabled and available.
if (SystemTrayIcon::isSystemTrayActivated()) {
qApp->showTrayIcon();
}
if (qApp->isFirstRun() || qApp->isFirstRun(APP_VERSION)) {
qApp->showGuiMessage(QSL(APP_NAME), QObject::tr("Welcome to %1.\n\nPlease, check NEW stuff included in this\n"
"version by clicking this popup notification.").arg(APP_LONG_NAME),
QSystemTrayIcon::NoIcon, 0, false, &main_window, SLOT(showAbout()));
}
else {
qApp->showGuiMessage(QSL(APP_NAME), QObject::tr("Welcome to %1.").arg(APP_NAME), QSystemTrayIcon::NoIcon);
}
if (qApp->settings()->value(GROUP(General), SETTING(General::UpdateOnStartup)).toBool()) {
QTimer::singleShot(STARTUP_UPDATE_DELAY, application.system(), SLOT(checkForUpdatesOnStartup()));
}
qApp->mainForm()->tabWidget()->feedMessageViewer()->feedsView()->loadAllExpandStates();
// Enter global event loop.
return Application::exec();
// Display main window.
if (qApp->settings()->value(GROUP(GUI), SETTING(GUI::MainWindowStartsHidden)).toBool() && SystemTrayIcon::isSystemTrayActivated()) {
qDebug("Hiding the main window when the application is starting.");
main_window.switchVisibility(true);
}
else {
return Application::exec();
qDebug("Showing the main window when the application is starting.");
main_window.show();
}
// Display tray icon if it is enabled and available.
if (SystemTrayIcon::isSystemTrayActivated()) {
qApp->showTrayIcon();
}
if (qApp->isFirstRun() || qApp->isFirstRun(APP_VERSION)) {
qApp->showGuiMessage(QSL(APP_NAME), QObject::tr("Welcome to %1.\n\nPlease, check NEW stuff included in this\n"
"version by clicking this popup notification.").arg(APP_LONG_NAME),
QSystemTrayIcon::NoIcon, 0, false, &main_window, SLOT(showAbout()));
}
else {
qApp->showGuiMessage(QSL(APP_NAME), QObject::tr("Welcome to %1.").arg(APP_NAME), QSystemTrayIcon::NoIcon);
}
if (qApp->settings()->value(GROUP(General), SETTING(General::UpdateOnStartup)).toBool()) {
QTimer::singleShot(STARTUP_UPDATE_DELAY, application.system(), SLOT(checkForUpdatesOnStartup()));
}
qApp->mainForm()->tabWidget()->feedMessageViewer()->feedsView()->loadAllExpandStates();
// Enter global event loop.
return Application::exec();
}

View File

@ -43,9 +43,9 @@
#include <QWebEngineDownloadItem>
#endif
Application::Application(const QString &id, bool run_minimal_without_gui, int &argc, char **argv)
Application::Application(const QString &id, int &argc, char **argv)
: QtSingleApplication(id, argc, argv),
m_runMinimalWithoutGui(run_minimal_without_gui), m_feedReader(nullptr),
m_feedReader(nullptr),
m_updateFeedsLock(nullptr), m_userActions(QList<QAction*>()), m_mainForm(nullptr),
m_trayIcon(nullptr), m_settings(nullptr), m_system(nullptr), m_skins(nullptr),
m_localization(nullptr), m_icons(nullptr), m_database(nullptr), m_downloadManager(nullptr) {
@ -247,7 +247,7 @@ void Application::processExecutionMessage(const QString &message) {
if (messages.contains(APP_QUIT_INSTANCE)) {
quit();
}
else if (!m_runMinimalWithoutGui) {
else {
foreach (const QString &msg, messages) {
if (msg == APP_IS_RUNNING) {
showGuiMessage(APP_NAME, tr("Application is already running."), QSystemTrayIcon::Information);
@ -301,10 +301,7 @@ void Application::showGuiMessage(const QString &title, const QString &message,
QSystemTrayIcon::MessageIcon message_type, QWidget *parent,
bool show_at_least_msgbox, QObject *invokation_target,
const char *invokation_slot) {
if (m_runMinimalWithoutGui) {
qDebug("Silencing GUI message: '%s'.", qPrintable(message));
}
else if (SystemTrayIcon::areNotificationsEnabled() && SystemTrayIcon::isSystemTrayActivated()) {
if (SystemTrayIcon::areNotificationsEnabled() && SystemTrayIcon::isSystemTrayActivated()) {
trayIcon()->showMessage(title, message, message_type, TRAY_ICON_BUBBLE_TIMEOUT, invokation_target, invokation_slot);
}
else if (show_at_least_msgbox) {

View File

@ -53,7 +53,7 @@ class Application : public QtSingleApplication {
public:
// Constructors and destructors.
explicit Application(const QString &id, bool run_minimal_without_gui, int &argc, char **argv);
explicit Application(const QString &id, int &argc, char **argv);
virtual ~Application();
FeedReader *feedReader();
@ -128,7 +128,6 @@ class Application : public QtSingleApplication {
void eliminateFirstRun();
void eliminateFirstRun(const QString &version);
bool m_runMinimalWithoutGui;
FeedReader *m_feedReader;
// This read-write lock is used by application on its close.