Changeset View
Changeset View
Standalone View
Standalone View
libs/ui/KisMainWindow.cpp
Show First 20 Lines • Show All 54 Lines • ▼ Show 20 Line(s) | |||||
55 | #include <QMenu> | 55 | #include <QMenu> | ||
56 | #include <QMenuBar> | 56 | #include <QMenuBar> | ||
57 | #include <KisMimeDatabase.h> | 57 | #include <KisMimeDatabase.h> | ||
58 | #include <QMimeData> | 58 | #include <QMimeData> | ||
59 | #include <QStackedWidget> | 59 | #include <QStackedWidget> | ||
60 | #include <QProxyStyle> | 60 | #include <QProxyStyle> | ||
61 | #include <QScreen> | 61 | #include <QScreen> | ||
62 | #include <QAction> | 62 | #include <QAction> | ||
63 | #include <QWindow> | ||||
63 | 64 | | |||
64 | #include <kactioncollection.h> | 65 | #include <kactioncollection.h> | ||
65 | #include <kactionmenu.h> | 66 | #include <kactionmenu.h> | ||
66 | #include <kis_debug.h> | 67 | #include <kis_debug.h> | ||
67 | #include <kedittoolbar.h> | 68 | #include <kedittoolbar.h> | ||
68 | #include <khelpmenu.h> | 69 | #include <khelpmenu.h> | ||
69 | #include <klocalizedstring.h> | 70 | #include <klocalizedstring.h> | ||
70 | #include <kaboutdata.h> | 71 | #include <kaboutdata.h> | ||
▲ Show 20 Lines • Show All 460 Lines • ▼ Show 20 Line(s) | 529 | if (cfg.readEntry("CanvasOnlyActive", false)) { | |||
531 | KisWorkspaceResource* workspace = rserver->resourceByName(currentWorkspace); | 532 | KisWorkspaceResource* workspace = rserver->resourceByName(currentWorkspace); | ||
532 | if (workspace) { | 533 | if (workspace) { | ||
533 | restoreWorkspace(workspace); | 534 | restoreWorkspace(workspace); | ||
534 | } | 535 | } | ||
535 | cfg.writeEntry("CanvasOnlyActive", false); | 536 | cfg.writeEntry("CanvasOnlyActive", false); | ||
536 | menuBar()->setVisible(true); | 537 | menuBar()->setVisible(true); | ||
537 | } | 538 | } | ||
538 | 539 | | |||
540 | this->winId(); // Ensures the native window has been created. | ||||
541 | QWindow *window = this->windowHandle(); | ||||
542 | connect(window, SIGNAL(screenChanged(QScreen *)), this, SLOT(windowScreenChanged(QScreen *))); | ||||
539 | 543 | | |||
540 | } | 544 | } | ||
541 | 545 | | |||
542 | KisMainWindow::~KisMainWindow() | 546 | KisMainWindow::~KisMainWindow() | ||
543 | { | 547 | { | ||
544 | // Q_FOREACH (QAction *ac, actionCollection()->actions()) { | 548 | // Q_FOREACH (QAction *ac, actionCollection()->actions()) { | ||
545 | // QAction *action = qobject_cast<QAction*>(ac); | 549 | // QAction *action = qobject_cast<QAction*>(ac); | ||
546 | // if (action) { | 550 | // if (action) { | ||
▲ Show 20 Lines • Show All 2086 Lines • ▼ Show 20 Line(s) | 2600 | { | |||
2633 | d->fullScreenMode->setChecked(isFullScreen()); | 2637 | d->fullScreenMode->setChecked(isFullScreen()); | ||
2634 | } | 2638 | } | ||
2635 | 2639 | | |||
2636 | void KisMainWindow::showManual() | 2640 | void KisMainWindow::showManual() | ||
2637 | { | 2641 | { | ||
2638 | QDesktopServices::openUrl(QUrl("https://docs.krita.org")); | 2642 | QDesktopServices::openUrl(QUrl("https://docs.krita.org")); | ||
2639 | } | 2643 | } | ||
2640 | 2644 | | |||
2641 | void KisMainWindow::moveEvent(QMoveEvent *e) | 2645 | void KisMainWindow::windowScreenChanged(QScreen *screen) | ||
2642 | { | 2646 | { | ||
2643 | /** | | |||
2644 | * For checking if the display number has changed or not we should always use | | |||
2645 | * positional overload, not using QWidget overload. Otherwise we might get | | |||
2646 | * inconsistency, because screenNumber(widget) can return -1, but screenNumber(pos) | | |||
2647 | * will always return the nearest screen. | | |||
2648 | */ | | |||
2649 | | ||||
2650 | const int oldScreen = qApp->desktop()->screenNumber(e->oldPos()); | | |||
2651 | const int newScreen = qApp->desktop()->screenNumber(e->pos()); | | |||
2652 | | ||||
2653 | if (oldScreen != newScreen) { | | |||
2654 | emit screenChanged(); | 2647 | emit screenChanged(); | ||
2655 | } | | |||
2656 | | ||||
2657 | if (d->screenConnectionsStore.isEmpty() || oldScreen != newScreen) { | | |||
2658 | | ||||
2659 | d->screenConnectionsStore.clear(); | 2648 | d->screenConnectionsStore.clear(); | ||
2660 | 2649 | d->screenConnectionsStore.addConnection(screen, SIGNAL(physicalDotsPerInchChanged(qreal)), | |||
2661 | QScreen *newScreenObject = 0; | | |||
2662 | | ||||
2663 | #if QT_VERSION >= QT_VERSION_CHECK(5, 10, 0) | | |||
2664 | newScreenObject = qApp->screenAt(e->pos()); | | |||
2665 | #else | | |||
2666 | // TODO: i'm not sure if this pointer already has a correct value | | |||
2667 | // by the moment we get the event. It might not work on older | | |||
2668 | // versions of Qt | | |||
2669 | newScreenObject = qApp->primaryScreen(); | | |||
2670 | #endif | | |||
2671 | | ||||
2672 | if (newScreenObject) { | | |||
2673 | d->screenConnectionsStore.addConnection(newScreenObject, SIGNAL(physicalDotsPerInchChanged(qreal)), | | |||
2674 | this, SIGNAL(screenChanged())); | 2650 | this, SIGNAL(screenChanged())); | ||
2675 | } | 2651 | } | ||
2676 | } | | |||
2677 | } | | |||
2678 | 2652 | | |||
2679 | 2653 | | |||
2680 | 2654 | | |||
2681 | #include <moc_KisMainWindow.cpp> | 2655 | #include <moc_KisMainWindow.cpp> |