QT_BEGIN_NAMESPACE QQuickPopupWindow::QQuickPopupWindow() : QQuickWindow(), m_parentItem(0), m_contentItem(0), m_mouseMoved(false), m_needsActivatedEvent(true), m_dismissed(false) { setFlags(Qt::Popup); connect(qApp, SIGNAL(applicationStateChanged(Qt::ApplicationState)), this, SLOT(applicationStateChanged(Qt::ApplicationState))); }
popupWindow::popupWindow() : QQuickWindow() { setFlags(Qt::Tool | Qt::Window | Qt::FramelessWindowHint); //setFlags(Qt::Popup); m_dismissed = false; m_mouseMoved = false; m_needsActivatedEvent = true; m_xOffset = 0; m_yOffset = 0; connect(qApp, SIGNAL(applicationStateChanged(Qt::ApplicationState)), this, SLOT(applicationStateChanged(Qt::ApplicationState))); }
MarbleMaps::MarbleMaps(QQuickItem *parent) : MarbleQuickItem(parent), m_suspended(false) { QGuiApplication* application = qobject_cast<QGuiApplication*>(QGuiApplication::instance()); if (application) { connect(application, SIGNAL(applicationStateChanged(Qt::ApplicationState)), this, SLOT(handleApplicationStateChange(Qt::ApplicationState))); } #ifdef Q_OS_ANDROID // If a file is passed, open it. Possible file types are registered in package/AndroidManifest.xml QAndroidJniObject const activity = QtAndroid::androidActivity(); if (activity.isValid()) { QAndroidJniObject const intent = activity.callObjectMethod("getIntent", "()Landroid/content/Intent;"); if (intent.isValid()) { QAndroidJniObject const data = intent.callObjectMethod("getData", "()Landroid/net/Uri;"); if (data.isValid()) { QAndroidJniObject const path = data.callObjectMethod("getPath", "()Ljava/lang/String;"); if (path.isValid()) { model()->addGeoDataFile(path.toString()); connect( model()->fileManager(), SIGNAL(centeredDocument(GeoDataLatLonBox)), this, SLOT(centerOn(GeoDataLatLonBox)) ); } } } } #endif }
QAndroidCameraSession::QAndroidCameraSession(QObject *parent) : QObject(parent) , m_selectedCamera(0) , m_camera(0) , m_nativeOrientation(0) , m_videoOutput(0) , m_captureMode(QCamera::CaptureViewfinder) , m_state(QCamera::UnloadedState) , m_savedState(-1) , m_status(QCamera::UnloadedStatus) , m_previewStarted(false) , m_imageSettingsDirty(true) , m_captureDestination(QCameraImageCapture::CaptureToFile) , m_captureImageDriveMode(QCameraImageCapture::SingleImageCapture) , m_lastImageCaptureId(0) , m_readyForCapture(false) , m_captureCanceled(false) , m_currentImageCaptureId(-1) , m_previewCallback(0) { m_mediaStorageLocation.addStorageLocation( QMediaStorageLocation::Pictures, AndroidMultimediaUtils::getDefaultMediaDirectory(AndroidMultimediaUtils::DCIM)); if (qApp) { connect(qApp, SIGNAL(applicationStateChanged(Qt::ApplicationState)), this, SLOT(onApplicationStateChanged(Qt::ApplicationState))); } }
Application::Application( int& argc, char** argv ) : QApplication(argc, argv) { #if defined(ANDROID) || defined(SIMPLE) || defined(IOS) QObject::connect( this, SIGNAL(applicationStateChanged(Qt::ApplicationState)), this, SLOT(stateChanged(Qt::ApplicationState)) ); #endif }
PhoneScreenSyncer::PhoneScreenSyncer(QObject *parent) : QObject(parent) { qRegisterMetaType<Qt::ApplicationState>("Qt::ApplicationState"); connect(qApp, SIGNAL(applicationStateChanged(Qt::ApplicationState)), this, SLOT(on_applicationStateChanged(Qt::ApplicationState))); connect(&mTimer, SIGNAL(timeout()), this, SLOT(syncScreen())); mTimer.setInterval(1000); mTimer.start(); }
QT_BEGIN_NAMESPACE /* This object and its properties are documented as part of the Qt object, in qqmlengine.cpp */ QQuickApplication::QQuickApplication(QObject *parent) : QQmlApplication(parent) { if (qApp) { connect(qApp, SIGNAL(layoutDirectionChanged(Qt::LayoutDirection)), this, SIGNAL(layoutDirectionChanged())); connect(qApp, SIGNAL(applicationStateChanged(Qt::ApplicationState)), this, SIGNAL(stateChanged(Qt::ApplicationState))); connect(qApp, SIGNAL(applicationStateChanged(Qt::ApplicationState)), this, SIGNAL(activeChanged())); } }
void GLCanvas::initializeGL() { Application::getInstance()->initializeGL(); setAttribute(Qt::WA_AcceptTouchEvents); setAcceptDrops(true); connect(Application::getInstance(), SIGNAL(applicationStateChanged(Qt::ApplicationState)), this, SLOT(activeChanged(Qt::ApplicationState))); connect(&_frameTimer, SIGNAL(timeout()), this, SLOT(throttleRender())); // Note, we *DO NOT* want Qt to automatically swap buffers for us. This results in the "ringing" bug mentioned in WL#19514 when we're throttling the framerate. setAutoBufferSwap(false); }
void QAndroidInputContext::showInputPanel() { if (QGuiApplication::applicationState() != Qt::ApplicationActive) { connect(qGuiApp, SIGNAL(applicationStateChanged(Qt::ApplicationState)), this, SLOT(showInputPanelLater(Qt::ApplicationState))); return; } QSharedPointer<QInputMethodQueryEvent> query = focusObjectInputMethodQueryThreadSafe(); if (query.isNull()) return; disconnect(m_updateCursorPosConnection); if (qGuiApp->focusObject()->metaObject()->indexOfSignal("cursorPositionChanged(int,int)") >= 0) // QLineEdit breaks the pattern m_updateCursorPosConnection = connect(qGuiApp->focusObject(), SIGNAL(cursorPositionChanged(int,int)), this, SLOT(updateCursorPosition())); else
PhWindow::PhWindow(PhWindowSettings *settings) : QMainWindow(NULL), _settings(settings) { // Set up a filter for catching event this->installEventFilter(this); if(_settings->fullScreen()) { PHDEBUG << "Going fullscreen..."; QTimer::singleShot(1000, this, SLOT(showFullScreen())); } connect(qApp, SIGNAL(applicationStateChanged(Qt::ApplicationState)), this, SLOT(onApplicationStateChange(Qt::ApplicationState))); }
QLock::QLock(LockedObjShared_t handler, bool unlockOnSleep) : handler_(handler) { // If we have just QCoreApplicaion instance, we don't have UI and don't have // any active/inactive states, so we just assume that we're always active. if (QGuiApplication::instance()->metaObject()->indexOfSignal("applicationStateChanged(Qt::ApplicationState)") >= 0 && unlockOnSleep) { QObject::connect( QGuiApplication::instance(), SIGNAL(applicationStateChanged(Qt::ApplicationState)), this, SLOT(onApplicationStateChanged(Qt::ApplicationState))); } handler->lock(); }
GUIManager::GUIManager(QWidget *parent) : QWidget(parent, Qt::Window) { #ifdef Q_OS_OSX if(Options::independentWindowINDI()) setWindowFlags(Qt::Window); else{ setWindowFlags(Qt::Window | Qt::WindowStaysOnTopHint); connect(QApplication::instance(), SIGNAL(applicationStateChanged(Qt::ApplicationState)), this, SLOT(changeAlwaysOnTop(Qt::ApplicationState))); } #endif mainLayout = new QVBoxLayout(this); mainLayout->setMargin(10); mainLayout->setSpacing(10); mainTabWidget = new QTabWidget(this); mainLayout->addWidget(mainTabWidget); setWindowIcon(QIcon::fromTheme("kstars_indi", QIcon(":/icons/breeze/default/kstars_indi.svg"))); setWindowTitle(i18n("INDI Control Panel")); setAttribute(Qt::WA_ShowModal, false); clearB = new QPushButton(i18n("Clear")); closeB = new QPushButton(i18n("Close")); QHBoxLayout *buttonLayout = new QHBoxLayout; buttonLayout->insertStretch(0); buttonLayout->addWidget(clearB, 0, Qt::AlignRight); buttonLayout->addWidget(closeB, 0, Qt::AlignRight); mainLayout->addLayout(buttonLayout); connect(closeB, SIGNAL(clicked()), this, SLOT(close())); connect(clearB, SIGNAL(clicked()), this, SLOT(clearLog())); resize( 640, 480); }
MainWindow::MainWindow() { setWindowIcon(QIcon(":/images/seafile.png")); setWindowTitle(getBrand()); // Qt::Tool hides the taskbar entry on windows // setWindowFlags(Qt::FramelessWindowHint | Qt::Tool | Qt::WindowStaysOnTopHint); setWindowFlags(Qt::Window #if !defined(Q_OS_MAC) | Qt::FramelessWindowHint #endif #if (QT_VERSION < QT_VERSION_CHECK(5, 0, 0)) | Qt::WindowMinimizeButtonHint #endif | Qt::WindowSystemMenuHint); cloud_view_ = new CloudView; QVBoxLayout *layout = new QVBoxLayout; layout->setContentsMargins(0, 0, 0, 0); layout->addWidget(cloud_view_); QWidget *wrapper = new QWidget; wrapper->setObjectName("mainWrapper"); wrapper->setLayout(layout); setCentralWidget(wrapper); createActions(); setAttribute(Qt::WA_TranslucentBackground, true); #if (QT_VERSION >= QT_VERSION_CHECK(5, 2, 0)) connect(qApp, SIGNAL(applicationStateChanged(Qt::ApplicationState)), this, SLOT(checkShowWindow())); #endif }
void Tasty::_init() { #ifdef QT_DEBUG static bool inited = false; Q_ASSERT(!inited); inited = true; auto now = QDateTime::currentMSecsSinceEpoch(); #endif Bayes::instance(this); _engine = new QQmlApplicationEngine(this); _settings = new Settings(this); _manager = _engine->networkAccessManager(); _pusher = new PusherClient(this); _dataCache = new TastyDataCache; _entryImageWidth = _settings->maxImageWidth(); _commentImageWidth = _entryImageWidth; Q_TEST(connect(qApp, SIGNAL(applicationStateChanged(Qt::ApplicationState)), this, SLOT(_saveOrReconnect(Qt::ApplicationState)))); Q_TEST(connect(_manager, SIGNAL(networkAccessibleChanged(QNetworkAccessManager::NetworkAccessibility)), this, SLOT(_showNetAccessibility(QNetworkAccessManager::NetworkAccessibility)))); Q_TEST(connect(_pusher, SIGNAL(unreadChats(int)), this, SLOT(_setUnreadChats(int)))); Q_TEST(connect(_pusher, SIGNAL(unreadNotifications(int)), this, SLOT(_setUnreadNotifications(int)))); Q_TEST(connect(_pusher, SIGNAL(unreadFriendsEntry(int)), this, SLOT(_incUnreadFriendsEntries()))); QQuickStyle::setStyle("Material"); qmlRegisterType<FeedModel> ("org.binque.taaasty", 1, 0, "FeedModel"); qmlRegisterType<CalendarModel> ("org.binque.taaasty", 1, 0, "CalendarModel"); qmlRegisterType<CommentsModel> ("org.binque.taaasty", 1, 0, "CommentsModel"); qmlRegisterType<AttachedImagesModel>("org.binque.taaasty", 1, 0, "AttachedImagesModel"); qmlRegisterType<UsersModel> ("org.binque.taaasty", 1, 0, "UsersModel"); qmlRegisterType<MessagesModel> ("org.binque.taaasty", 1, 0, "MessagesModel"); qmlRegisterType<FlowsModel> ("org.binque.taaasty", 1, 0, "FlowsModel"); qmlRegisterType<TagsModel> ("org.binque.taaasty", 1, 0, "TagsModel"); qmlRegisterType<Entry> ("org.binque.taaasty", 1, 0, "TlogEntry"); qmlRegisterType<CalendarEntry> ("org.binque.taaasty", 1, 0, "CalendarEntry"); qmlRegisterType<Comment> ("org.binque.taaasty", 1, 0, "Comment"); qmlRegisterType<User> ("org.binque.taaasty", 1, 0, "User"); qmlRegisterType<Author> ("org.binque.taaasty", 1, 0, "Author"); qmlRegisterType<Tlog> ("org.binque.taaasty", 1, 0, "Tlog"); qmlRegisterType<Rating> ("org.binque.taaasty", 1, 0, "Rating"); qmlRegisterType<AttachedImage> ("org.binque.taaasty", 1, 0, "AttachedImage"); qmlRegisterType<Media> ("org.binque.taaasty", 1, 0, "Media"); qmlRegisterType<Notification> ("org.binque.taaasty", 1, 0, "Notification"); qmlRegisterType<Message> ("org.binque.taaasty", 1, 0, "Message"); qmlRegisterType<MessageBase> ("org.binque.taaasty", 1, 0, "MessageBase"); qmlRegisterType<Conversation> ("org.binque.taaasty", 1, 0, "Chat"); qmlRegisterType<Flow> ("org.binque.taaasty", 1, 0, "Flow"); qmlRegisterType<TextHandler> ("org.binque.taaasty", 1, 0, "TextHandler"); qmlRegisterType<Poster> ("org.binque.taaasty", 1, 0, "Poster"); qmlRegisterType<CachedImage>("ImageCache", 2, 0, "CachedImage"); auto root = _engine->rootContext(); root->setContextProperty("Tasty", this); root->setContextProperty("Settings", _settings); auto notifs = NotificationsModel::instance(this); root->setContextProperty("NotifsModel", notifs); auto friendActivity = NotificationsModel::friendActivity(this); root->setContextProperty("FriendActivityModel", friendActivity); auto chats = ChatsModel::instance(this); root->setContextProperty("ChatsModel", chats); auto cache = CacheManager::instance(_manager); cache->setMaxWidth(_settings->maxImageWidth()); cache->setAutoloadOverWifi(_settings->loadImagesOverWifi()); cache->setMaxLoadSize(_settings->maxLoadImageSize()); root->setContextProperty("Cache", cache); Q_TEST(QObject::connect(_settings, SIGNAL(loadImagesOverWifiChanged(bool)), cache, SLOT(setAutoloadOverWifi(bool)))); Q_TEST(QObject::connect(_settings, SIGNAL(maxLoadImageSizeChanged(int)), cache, SLOT(setMaxLoadSize(int)))); auto bayes = Bayes::instance(); root->setContextProperty("Bayes", bayes); auto trainer = bayes->trainer(); root->setContextProperty("Trainer", trainer); #ifdef Q_OS_ANDROID float density = 160; #else float density = 267; // test #endif double scale = density < 180 ? 1 : density < 270 ? 1.5 : density < 360 ? 2 : 3; root->setContextProperty("mm", density / 25.4); // N900: 1 mm = 10.5 px; Q10: 12.9 root->setContextProperty("pt", 1); root->setContextProperty("dp", scale); // N900: 1.5; Q10: 2 root->setContextProperty("sp", density / 160); // scaleable pixels root->setContextProperty("builtAt", QString::fromLatin1(__DATE__)); _engine->setBaseUrl(QStringLiteral("qrc:/qml/")); _engine->load(QUrl(QStringLiteral("main.qml"))); #ifdef QT_DEBUG auto ms = QDateTime::currentMSecsSinceEpoch() - now; qDebug() << "Started in" << ms << "ms"; #endif }
Widget::Widget(QWidget *parent) : QWidget(parent) { connect(qApp, SIGNAL(applicationStateChanged(Qt::ApplicationState)), this, SLOT(onAppStateChanged(Qt::ApplicationState))); QGridLayout *layout = new QGridLayout(this); layout->setColumnStretch(1, 1); m_networkState = new QLabel(); layout->addWidget(m_networkState, 0, 0, 1, 2); m_connectButton = new QPushButton("Connect"); connect(m_connectButton, SIGNAL(clicked()), this, SLOT(onConnectButton())); layout->addWidget(m_connectButton, 0, 2); checkNetworkState(); layout->addWidget(new QLabel("Toast:"), 1, 0); m_toastEdit = new QLineEdit("Qt toast"); layout->addWidget(m_toastEdit, 1, 1); m_toastButton = new QPushButton("makeToast"); layout->addWidget(m_toastButton, 1, 2); connect(m_toastButton, SIGNAL(clicked()), this , SLOT(onToastButton())); layout->addWidget(new QLabel("通知:"), 2, 0); m_notificationEdit = new QLineEdit("Qt notification"); layout->addWidget(m_notificationEdit, 2, 1); m_notifyButton = new QPushButton("Send"); connect(m_notifyButton, SIGNAL(clicked()), this, SLOT(onNotifyButton())); layout->addWidget(m_notifyButton, 2, 2); layout->addWidget(new QLabel("广播:"), 3, 0); m_broadcastEdit = new QLineEdit("an.qt.extendsQt.test"); layout->addWidget(m_broadcastEdit, 3, 1); m_broadcastButton = new QPushButton("Send"); connect(m_broadcastButton, SIGNAL(clicked()), this, SLOT(onBroadcastButton())); layout->addWidget(m_broadcastButton, 3, 2); layout->addWidget(new QLabel("Activity:"), 4, 0); m_activityEdit = new QLineEdit("android.settings.SETTINGS"); layout->addWidget(m_activityEdit, 4, 1); m_activityButton = new QPushButton("Start"); connect(m_activityButton, SIGNAL(clicked()), this, SLOT(onActivityButton())); layout->addWidget(m_activityButton, 4, 2); layout->addWidget(new QLabel("Location:"), 5, 0); m_locationState = new QLabel; layout->addWidget(m_locationState, 5, 1); QPushButton * btn = new QPushButton("Get"); connect(btn, SIGNAL(clicked()), this, SLOT(onGetLocation())); layout->addWidget(btn, 5, 2); layout->addWidget(new QLabel("CaptureImage:"), 6, 0); m_captureState = new QLabel; layout->addWidget(m_captureState, 6, 1); btn = new QPushButton("camera"); connect(btn, SIGNAL(clicked()), this, SLOT(onCaptureImage())); layout->addWidget(btn, 6, 2); layout->setRowStretch(7, 1); }
FITSViewer::FITSViewer (QWidget *parent) : KXmlGuiWindow (parent) { #ifdef Q_OS_OSX if(Options::independentWindowFITS()) setWindowFlags(Qt::Window); else{ setWindowFlags(Qt::Window | Qt::WindowStaysOnTopHint); connect(QApplication::instance(), SIGNAL(applicationStateChanged(Qt::ApplicationState)), this, SLOT(changeAlwaysOnTop(Qt::ApplicationState))); } #endif fitsTab = new QTabWidget(this); undoGroup = new QUndoGroup(this); fitsID = 0; debayerDialog= NULL; markStars = false; lastURL = QUrl(QDir::homePath()); fitsTab->setTabsClosable(true); setWindowIcon(QIcon::fromTheme("kstars_fitsviewer", QIcon(":/icons/breeze/default/kstars_fitsviewer.svg"))); setCentralWidget(fitsTab); connect(fitsTab, SIGNAL(currentChanged(int)), this, SLOT(tabFocusUpdated(int))); connect(fitsTab, SIGNAL(tabCloseRequested(int)), this, SLOT(closeTab(int))); //These two connections will enable or disable the scope button if a scope is available or not. //Of course this is also dependent on the presence of WCS data in the image. #ifdef HAVE_INDI connect(INDIListener::Instance(), SIGNAL(newTelescope(ISD::GDInterface *)), this, SLOT(updateWCSFunctions())); connect(INDIListener::Instance(), SIGNAL(deviceRemoved(ISD::GDInterface *)), this, SLOT(updateWCSFunctions())); #endif led.setColor(Qt::green); fitsPosition.setAlignment(Qt::AlignCenter); fitsValue.setAlignment(Qt::AlignCenter); //fitsPosition.setFixedWidth(100); //fitsValue.setFixedWidth(100); fitsWCS.setVisible(false); statusBar()->insertPermanentWidget(FITS_WCS, &fitsWCS); statusBar()->insertPermanentWidget(FITS_VALUE, &fitsValue); statusBar()->insertPermanentWidget(FITS_POSITION, &fitsPosition); statusBar()->insertPermanentWidget(FITS_ZOOM, &fitsZoom); statusBar()->insertPermanentWidget(FITS_RESOLUTION, &fitsResolution); statusBar()->insertPermanentWidget(FITS_LED, &led); QAction *action; action = actionCollection()->addAction("rotate_right", this, SLOT(rotateCW())); action->setText(i18n("Rotate Right")); action->setIcon(QIcon::fromTheme("object-rotate-right", QIcon(":/icons/breeze/default/object-rotate-right.svg"))); action = actionCollection()->addAction("rotate_left", this, SLOT(rotateCCW())); action->setText(i18n("Rotate Left")); action->setIcon(QIcon::fromTheme("object-rotate-left", QIcon(":/icons/breeze/default/object-rotate-left.svg"))); action = actionCollection()->addAction("flip_horizontal", this, SLOT(flipHorizontal())); action->setText(i18n("Flip Horizontal")); action->setIcon(QIcon::fromTheme("object-flip-horizontal", QIcon(":/icons/breeze/default/object-flip-horizontal.svg"))); action = actionCollection()->addAction("flip_vertical", this, SLOT(flipVertical())); action->setText(i18n("Flip Vertical")); action->setIcon(QIcon::fromTheme("object-flip-vertical", QIcon(":/icons/breeze/default/object-flip-vertical.svg"))); action = actionCollection()->addAction("image_histogram"); action->setText(i18n("Histogram")); connect(action, SIGNAL(triggered(bool)), SLOT (histoFITS())); actionCollection()->setDefaultShortcut(action, QKeySequence::Replace); action->setIcon(QIcon(":/icons/histogram.png")); action = KStandardAction::open(this, SLOT(openFile()), actionCollection()); action->setIcon(QIcon::fromTheme("document-open", QIcon(":/icons/breeze/default/document-open.svg"))); saveFileAction = KStandardAction::save(this, SLOT(saveFile()), actionCollection()); saveFileAction->setIcon(QIcon::fromTheme("document-save", QIcon(":/icons/breeze/default/document-save.svg"))); action=saveFileAsAction = KStandardAction::saveAs(this, SLOT(saveFileAs()), actionCollection()); saveFileAsAction->setIcon(QIcon::fromTheme("document-save_as", QIcon(":/icons/breeze/default/document-save-as.svg"))); action = actionCollection()->addAction("fits_header"); actionCollection()->setDefaultShortcut(action, QKeySequence(Qt::CTRL+Qt::Key_H)); action->setIcon(QIcon::fromTheme("document-properties", QIcon(":/icons/breeze/default/document-properties.svg"))); action->setText(i18n( "FITS Header")); connect(action, SIGNAL(triggered(bool) ), SLOT(headerFITS())); action = actionCollection()->addAction("fits_debayer"); actionCollection()->setDefaultShortcut(action, QKeySequence(Qt::CTRL+Qt::Key_D)); action->setIcon(QIcon::fromTheme("view-preview", QIcon(":/icons/breeze/default/view-preview.svg"))); action->setText(i18n( "Debayer...")); connect(action, SIGNAL(triggered(bool) ), SLOT(debayerFITS())); action = actionCollection()->addAction("image_stretch"); action->setText(i18n("Auto stretch")); connect(action, SIGNAL(triggered(bool)), SLOT (stretchFITS())); actionCollection()->setDefaultShortcut(action, QKeySequence::SelectAll); action->setIcon(QIcon::fromTheme("transform-move", QIcon(":/icons/breeze/default/transform-move.svg"))); action = KStandardAction::close(this, SLOT(close()), actionCollection()); action->setIcon(QIcon::fromTheme("window-close", QIcon(":/icons/breeze/default/window-close.svg"))); action = KStandardAction::copy(this, SLOT(copyFITS()), actionCollection()); action->setIcon(QIcon::fromTheme("edit-copy", QIcon(":/icons/breeze/default/edit-copy.svg"))); action=KStandardAction::zoomIn(this, SLOT(ZoomIn()), actionCollection()); action->setIcon(QIcon::fromTheme("zoom-in", QIcon(":/icons/breeze/default/zoom-in.svg"))); action=KStandardAction::zoomOut(this, SLOT(ZoomOut()), actionCollection()); action->setIcon(QIcon::fromTheme("zoom-out", QIcon(":/icons/breeze/default/zoom-out.svg"))); action=KStandardAction::actualSize(this, SLOT(ZoomDefault()), actionCollection()); action->setIcon(QIcon::fromTheme("zoom-fit-best", QIcon(":/icons/breeze/default/zoom-fit-best.svg"))); QAction *kundo = KStandardAction::undo(undoGroup, SLOT(undo()), actionCollection()); kundo->setIcon(QIcon::fromTheme("edit-undo", QIcon(":/icons/breeze/default/edit-undo.svg"))); QAction *kredo = KStandardAction::redo(undoGroup, SLOT(redo()), actionCollection()); kredo->setIcon(QIcon::fromTheme("edit-redo", QIcon(":/icons/breeze/default/edit-redo.svg"))); connect(undoGroup, SIGNAL(canUndoChanged(bool)), kundo, SLOT(setEnabled(bool))); connect(undoGroup, SIGNAL(canRedoChanged(bool)), kredo, SLOT(setEnabled(bool))); action = actionCollection()->addAction("image_stats"); action->setIcon(QIcon::fromTheme("view-statistics", QIcon(":/icons/breeze/default/view-statistics.svg"))); action->setText(i18n( "Statistics")); connect(action, SIGNAL(triggered(bool)), SLOT(statFITS())); action = actionCollection()->addAction("view_crosshair"); action->setIcon(QIcon::fromTheme("crosshairs", QIcon(":/icons/breeze/default/crosshairs.svg"))); action->setText(i18n( "Show Cross Hairs")); action->setCheckable(true); connect(action, SIGNAL(triggered(bool)), SLOT(toggleCrossHair())); action = actionCollection()->addAction("view_pixel_grid"); action->setIcon(QIcon::fromTheme("map-flat", QIcon(":/icons/breeze/default/map-flat.svg"))); action->setText(i18n( "Show Pixel Gridlines")); action->setCheckable(true); connect(action, SIGNAL(triggered(bool)), SLOT(togglePixelGrid())); action = actionCollection()->addAction("view_eq_grid"); action->setIcon(QIcon::fromTheme("kstars_grid", QIcon(":/icons/breeze/default/kstars_grid.svg"))); action->setText(i18n( "Show Equatorial Gridlines")); action->setCheckable(true); action->setDisabled(true); connect(action, SIGNAL(triggered(bool)), SLOT(toggleEQGrid())); action = actionCollection()->addAction("view_objects"); action->setIcon(QIcon::fromTheme("help-hint", QIcon(":/icons/breeze/default/help-hint.svg"))); action->setText(i18n( "Show Objects in Image")); action->setCheckable(true); action->setDisabled(true); connect(action, SIGNAL(triggered(bool)), SLOT(toggleObjects())); action = actionCollection()->addAction("center_telescope"); action->setIcon(QIcon(":/icons/center_telescope.svg")); action->setText(i18n( "Center Telescope\n*No Telescopes Detected*")); action->setDisabled(true); action->setCheckable(true); connect(action, SIGNAL(triggered(bool)), SLOT(centerTelescope())); action = actionCollection()->addAction("view_zoom_fit"); action->setIcon(QIcon::fromTheme("zoom-fit-width", QIcon(":/icons/breeze/default/zoom-fit-width.svg"))); action->setText(i18n( "Zoom To Fit")); connect(action, SIGNAL(triggered(bool)), SLOT(ZoomToFit())); action = actionCollection()->addAction("mark_stars"); action->setText(i18n( "Mark Stars")); connect(action, SIGNAL(triggered(bool)), SLOT(toggleStars())); QSignalMapper *filterMapper = new QSignalMapper(this); int filterCounter=1; foreach(QString filter, FITSViewer::filterTypes) { action = actionCollection()->addAction(QString("filter%1").arg(filterCounter)); action->setText(i18n(filter.toUtf8().constData())); filterMapper->setMapping(action, filterCounter++); connect(action, SIGNAL(triggered()), filterMapper, SLOT(map())); }
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { ui->setupUi(this); mainWindow = this; // Start device manager KbManager::init(CKB_VERSION_STR); connect(KbManager::kbManager(), SIGNAL(kbConnected(Kb*)), this, SLOT(addDevice(Kb*))); connect(KbManager::kbManager(), SIGNAL(kbDisconnected(Kb*)), this, SLOT(removeDevice(Kb*))); connect(KbManager::kbManager(), SIGNAL(versionUpdated()), this, SLOT(updateVersion())); connect(KbManager::scanTimer(), SIGNAL(timeout()), this, SLOT(timerTick())); // Set up tray icon restoreAction = new QAction(tr("Restore"), this); closeAction = new QAction(tr("Quit ckb"), this); #ifdef USE_LIBAPPINDICATOR QString desktop = std::getenv("XDG_CURRENT_DESKTOP"); unityDesktop = (desktop.toLower() == "unity"); if(unityDesktop){ trayIcon = 0; indicatorMenu = gtk_menu_new(); indicatorMenuRestoreItem = gtk_menu_item_new_with_label("Restore"); indicatorMenuQuitItem = gtk_menu_item_new_with_label("Quit ckb"); gtk_menu_shell_append(GTK_MENU_SHELL(indicatorMenu), indicatorMenuRestoreItem); gtk_menu_shell_append(GTK_MENU_SHELL(indicatorMenu), indicatorMenuQuitItem); g_signal_connect(indicatorMenuQuitItem, "activate", G_CALLBACK(quitIndicator), this); g_signal_connect(indicatorMenuRestoreItem, "activate", G_CALLBACK(restoreIndicator), this); gtk_widget_show(indicatorMenuRestoreItem); gtk_widget_show(indicatorMenuQuitItem); indicator = app_indicator_new("ckb", "indicator-messages", APP_INDICATOR_CATEGORY_APPLICATION_STATUS); app_indicator_set_status(indicator, APP_INDICATOR_STATUS_ACTIVE); app_indicator_set_menu(indicator, GTK_MENU(indicatorMenu)); app_indicator_set_icon(indicator, "ckb"); } else #endif // USE_LIBAPPINDICATOR { trayIconMenu = new QMenu(this); trayIconMenu->addAction(restoreAction); trayIconMenu->addAction(closeAction); trayIcon = new QSystemTrayIcon(QIcon(":/img/ckb-logo.png"), this); trayIcon->setContextMenu(trayIconMenu); connect(trayIcon, SIGNAL(activated(QSystemTrayIcon::ActivationReason)), this, SLOT(iconClicked(QSystemTrayIcon::ActivationReason))); } toggleTrayIcon(!CkbSettings::get("Program/SuppressTrayIcon").toBool()); #ifdef Q_OS_MACX // Make a custom "Close" menu action for OSX, as the default one brings up the "still running" popup unnecessarily QMenuBar* menuBar = new QMenuBar(this); setMenuBar(menuBar); this->menuBar()->addMenu("ckb")->addAction(closeAction); #else // On linux, add a handler for Ctrl+Q new QShortcut(QKeySequence("Ctrl+Q"), this, SLOT(quitApp())); #endif connect(ui->actionExit, SIGNAL(triggered()), this, SLOT(quitApp())); connect(closeAction, SIGNAL(triggered()), this, SLOT(quitApp())); connect(restoreAction, SIGNAL(triggered()), this, SLOT(showWindow())); connect(qApp, SIGNAL(applicationStateChanged(Qt::ApplicationState)), this, SLOT(stateChange(Qt::ApplicationState))); connect(qApp, SIGNAL(aboutToQuit()), this, SLOT(cleanup())); ui->tabWidget->addTab(settingsWidget = new SettingsWidget(this), configLabel); settingsWidget->setVersion("ckb " CKB_VERSION_STR); }
Application::Application(int &argc, char **argv) : PsApplication(argc, argv), serverName(psServerPrefix() + cGUIDStr()), closing(false), updateRequestId(0), updateReply(0), updateThread(0), updateDownloader(0) { DEBUG_LOG(("Application Info: creation..")); QByteArray d(QDir((cPlatform() == dbipWindows ? cExeDir() : cWorkingDir()).toLower()).absolutePath().toUtf8()); char h[33] = { 0 }; hashMd5Hex(d.constData(), d.size(), h); serverName = psServerPrefix() + h + '-' + cGUIDStr(); if (mainApp) { DEBUG_LOG(("Application Error: another Application was created, terminating..")); exit(0); } mainApp = this; installEventFilter(new _DebugWaiter(this)); #if defined Q_OS_LINUX || defined Q_OS_LINUX64 QFontDatabase::addApplicationFont(qsl(":/gui/art/fonts/DejaVuSans.ttf")); QFontDatabase::addApplicationFont(qsl(":/gui/art/fonts/NanumMyeongjo-Regular.ttf")); #endif QFontDatabase::addApplicationFont(qsl(":/gui/art/fonts/OpenSans-Regular.ttf")); QFontDatabase::addApplicationFont(qsl(":/gui/art/fonts/OpenSans-Bold.ttf")); QFontDatabase::addApplicationFont(qsl(":/gui/art/fonts/OpenSans-Semibold.ttf")); float64 dpi = primaryScreen()->logicalDotsPerInch(); if (dpi <= 108) { // 0-96-108 cSetScreenScale(dbisOne); } else if (dpi <= 132) { // 108-120-132 cSetScreenScale(dbisOneAndQuarter); } else if (dpi <= 168) { // 132-144-168 cSetScreenScale(dbisOneAndHalf); } else { // 168-192-inf cSetScreenScale(dbisTwo); } if (devicePixelRatio() > 1) { cSetRetina(true); cSetRetinaFactor(devicePixelRatio()); cSetIntRetinaFactor(int32(cRetinaFactor())); } if (!cLangFile().isEmpty()) { LangLoaderPlain loader(cLangFile()); if (!loader.errors().isEmpty()) { LOG(("Lang load errors: %1").arg(loader.errors())); } else if (!loader.warnings().isEmpty()) { LOG(("Lang load warnings: %1").arg(loader.warnings())); } } Local::start(); style::startManager(); anim::startManager(); historyInit(); DEBUG_LOG(("Application Info: inited..")); window = new Window(); psInstallEventFilter(); connect(&socket, SIGNAL(connected()), this, SLOT(socketConnected())); connect(&socket, SIGNAL(disconnected()), this, SLOT(socketDisconnected())); connect(&socket, SIGNAL(error(QLocalSocket::LocalSocketError)), this, SLOT(socketError(QLocalSocket::LocalSocketError))); connect(&socket, SIGNAL(bytesWritten(qint64)), this, SLOT(socketWritten(qint64))); connect(&socket, SIGNAL(readyRead()), this, SLOT(socketReading())); connect(&server, SIGNAL(newConnection()), this, SLOT(newInstanceConnected())); connect(this, SIGNAL(aboutToQuit()), this, SLOT(closeApplication())); connect(&updateCheckTimer, SIGNAL(timeout()), this, SLOT(startUpdateCheck())); connect(this, SIGNAL(updateFailed()), this, SLOT(onUpdateFailed())); connect(this, SIGNAL(updateReady()), this, SLOT(onUpdateReady())); connect(this, SIGNAL(applicationStateChanged(Qt::ApplicationState)), this, SLOT(onAppStateChanged(Qt::ApplicationState))); connect(&writeUserConfigTimer, SIGNAL(timeout()), this, SLOT(onWriteUserConfig())); writeUserConfigTimer.setSingleShot(true); connect(&killDownloadSessionsTimer, SIGNAL(timeout()), this, SLOT(killDownloadSessions())); if (cManyInstance()) { startApp(); } else { DEBUG_LOG(("Application Info: connecting local socket to %1..").arg(serverName)); socket.connectToServer(serverName); } }