Changeset View
Changeset View
Standalone View
Standalone View
krusader/krusader.cpp
Show First 20 Lines • Show All 102 Lines • ▼ Show 20 Line(s) | |||||
103 | #ifdef __KJSEMBED__ | 103 | #ifdef __KJSEMBED__ | ||
104 | KrJS *Krusader::js = 0; | 104 | KrJS *Krusader::js = 0; | ||
105 | QAction *Krusader::actShowJSConsole = 0; | 105 | QAction *Krusader::actShowJSConsole = 0; | ||
106 | #endif | 106 | #endif | ||
107 | 107 | | |||
108 | // construct the views, statusbar and menu bars and prepare Krusader to start | 108 | // construct the views, statusbar and menu bars and prepare Krusader to start | ||
109 | Krusader::Krusader(const QCommandLineParser &parser) : KParts::MainWindow(nullptr, | 109 | Krusader::Krusader(const QCommandLineParser &parser) : KParts::MainWindow(nullptr, | ||
110 | Qt::Window | Qt::WindowTitleHint | Qt::WindowContextHelpButtonHint), | 110 | Qt::Window | Qt::WindowTitleHint | Qt::WindowContextHelpButtonHint), | ||
111 | _listPanelActions(nullptr), isStarting(true), isExiting(false), _quit(false) | 111 | _listPanelActions(nullptr), isStarting(true), _quit(false) | ||
112 | { | 112 | { | ||
113 | // create the "krusader" | 113 | // create the "krusader" | ||
114 | App = this; | 114 | App = this; | ||
115 | krMainWindow = this; | 115 | krMainWindow = this; | ||
116 | SLOTS = new KRslots(this); | 116 | SLOTS = new KRslots(this); | ||
117 | setXMLFile("krusaderui.rc"); // kpart-related xml file | 117 | setXMLFile("krusaderui.rc"); // kpart-related xml file | ||
118 | 118 | | |||
119 | plzWait = new KRPleaseWaitHandler(this); | 119 | plzWait = new KRPleaseWaitHandler(this); | ||
▲ Show 20 Lines • Show All 162 Lines • ▼ Show 20 Line(s) | 281 | connect(startupInfo, &KStartupInfo::gotNewStartup, | |||
282 | this, &Krusader::slotGotNewStartup); | 282 | this, &Krusader::slotGotNewStartup); | ||
283 | connect(startupInfo, &KStartupInfo::gotRemoveStartup, | 283 | connect(startupInfo, &KStartupInfo::gotRemoveStartup, | ||
284 | this, &Krusader::slotGotRemoveStartup); | 284 | this, &Krusader::slotGotRemoveStartup); | ||
285 | } | 285 | } | ||
286 | 286 | | |||
287 | Krusader::~Krusader() | 287 | Krusader::~Krusader() | ||
288 | { | 288 | { | ||
289 | KrTrashHandler::stopWatcher(); | 289 | KrTrashHandler::stopWatcher(); | ||
290 | if (!isExiting) // save the settings if it was not saved (SIGTERM received) | | |||
291 | saveSettings(); | | |||
292 | 290 | | |||
293 | delete MAIN_VIEW; | 291 | delete MAIN_VIEW; | ||
294 | MAIN_VIEW = nullptr; | 292 | MAIN_VIEW = nullptr; | ||
295 | App = nullptr; | 293 | App = nullptr; | ||
296 | } | 294 | } | ||
297 | 295 | | |||
298 | void Krusader::setTray(bool forceCreation) | 296 | void Krusader::setTray(bool forceCreation) | ||
299 | { | 297 | { | ||
▲ Show 20 Lines • Show All 129 Lines • ▼ Show 20 Line(s) | 392 | void Krusader::saveSettings() { | |||
429 | // save popular links | 427 | // save popular links | ||
430 | _popularUrls->save(); | 428 | _popularUrls->save(); | ||
431 | 429 | | |||
432 | krConfig->sync(); | 430 | krConfig->sync(); | ||
433 | } | 431 | } | ||
434 | 432 | | |||
435 | void Krusader::closeEvent(QCloseEvent *event) | 433 | void Krusader::closeEvent(QCloseEvent *event) | ||
436 | { | 434 | { | ||
437 | if (!sysTray || _quit) { | 435 | if (sysTray && !_quit && !qApp->isSavingSession()) { | ||
438 | _quit = false; // in case quit will be aborted | 436 | // close to tray instead | ||
439 | KParts::MainWindow::closeEvent(event); // (may) quit, continues with queryClose()... | | |||
440 | } else { | | |||
441 | // close window to tray | | |||
442 | event->ignore(); | 437 | event->ignore(); | ||
443 | hide(); | 438 | hide(); | ||
439 | return; | ||||
444 | } | 440 | } | ||
441 | | ||||
442 | _quit = false; // in case quit will be aborted | ||||
443 | KParts::MainWindow::closeEvent(event); // (may) quit, continues with queryClose()... | ||||
445 | } | 444 | } | ||
446 | 445 | | |||
447 | void Krusader::showEvent(QShowEvent *event) | 446 | void Krusader::showEvent(QShowEvent *event) | ||
448 | { | 447 | { | ||
449 | const KConfigGroup lookFeelGroup(krConfig, "Look&Feel"); | 448 | const KConfigGroup lookFeelGroup(krConfig, "Look&Feel"); | ||
450 | if (sysTray && !lookFeelGroup.readEntry("Minimize To Tray", _ShowTrayIcon)) { | 449 | if (sysTray && !lookFeelGroup.readEntry("Minimize To Tray", _ShowTrayIcon)) { | ||
451 | // restoring from "start to tray", tray icon is not needed anymore | 450 | // restoring from "start to tray", tray icon is not needed anymore | ||
452 | sysTray->deleteLater(); | 451 | sysTray->deleteLater(); | ||
453 | } | 452 | } | ||
454 | 453 | | |||
455 | KParts::MainWindow::showEvent(event); | 454 | KParts::MainWindow::showEvent(event); | ||
456 | } | 455 | } | ||
457 | 456 | | |||
458 | bool Krusader::queryClose() { | 457 | bool Krusader::queryClose() { | ||
459 | if (isStarting || isExiting) | 458 | if (isStarting) | ||
460 | return false; | 459 | return false; | ||
461 | 460 | | |||
462 | if (qApp->isSavingSession()) { // KDE is logging out, accept the close | 461 | if (qApp->isSavingSession()) { // KDE is logging out, accept the close | ||
463 | acceptClose(); | 462 | acceptClose(); | ||
464 | return true; | 463 | return true; | ||
465 | } | 464 | } | ||
466 | 465 | | |||
467 | const KConfigGroup cfg = krConfig->group("Look&Feel"); | 466 | const KConfigGroup cfg = krConfig->group("Look&Feel"); | ||
▲ Show 20 Lines • Show All 52 Lines • ▼ Show 20 Line(s) | 516 | void Krusader::acceptClose() { | |||
520 | emit shutdown(); | 519 | emit shutdown(); | ||
521 | 520 | | |||
522 | // Removes the DBUS registration of the application. Single instance mode requires unique appid. | 521 | // Removes the DBUS registration of the application. Single instance mode requires unique appid. | ||
523 | // As Krusader is exiting, we release that unique appid, so new Krusader instances | 522 | // As Krusader is exiting, we release that unique appid, so new Krusader instances | ||
524 | // can be started. | 523 | // can be started. | ||
525 | 524 | | |||
526 | QDBusConnection dbus = QDBusConnection::sessionBus(); | 525 | QDBusConnection dbus = QDBusConnection::sessionBus(); | ||
527 | dbus.unregisterObject("/Instances/" + Krusader::AppName); | 526 | dbus.unregisterObject("/Instances/" + Krusader::AppName); | ||
528 | | ||||
529 | isExiting = true; | | |||
530 | } | 527 | } | ||
531 | 528 | | |||
532 | // the please wait dialog functions | 529 | // the please wait dialog functions | ||
533 | void Krusader::startWaiting(QString msg, int count , bool cancel) { | 530 | void Krusader::startWaiting(QString msg, int count , bool cancel) { | ||
534 | plzWait->startWaiting(std::move(msg) , count, cancel); | 531 | plzWait->startWaiting(std::move(msg) , count, cancel); | ||
535 | } | 532 | } | ||
536 | 533 | | |||
537 | bool Krusader::wasWaitingCancelled() const { | 534 | bool Krusader::wasWaitingCancelled() const { | ||
▲ Show 20 Lines • Show All 103 Lines • Show Last 20 Lines |