Пример #1
0
// Testing get/set functions
void tst_QSystemTrayIcon::showHide()
{
    QSystemTrayIcon icon;
    icon.setIcon(QIcon("icons/icon.png"));
    icon.show();
    icon.setIcon(QIcon("icons/icon.png"));
    icon.hide();
}
Пример #2
0
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);
    setWindowIcon(QIcon(":icons/icon.png"));
    setWindowTitle("quickly translate");
    QSystemTrayIcon * trayIcon = new QSystemTrayIcon(this);
    mNetManager = new QNetworkAccessManager(this);
    mLangageModel = new LanguageModel;

    trayIcon->setIcon(QIcon(":icons/icon.png"));

    trayIcon->setContextMenu(ui->menuFile);
    trayIcon->show();

    ui->dockWidget->hide();
    ui->sourceComboBox->setModel(mLangageModel);
    ui->targetComboBox->setModel(mLangageModel);

    QDesktopWidget * desktop = new QDesktopWidget;

    QPoint startPos = QPoint(desktop->geometry().bottomRight() );
    QPoint finalPos = desktop->geometry().center() - QPoint(width()/2,height()/2);

    move(finalPos);
    connect(trayIcon,SIGNAL(activated(QSystemTrayIcon::ActivationReason)),this,SLOT(trayActivated(QSystemTrayIcon::ActivationReason)));
    connect(ui->actionExit,SIGNAL(triggered()),this,SLOT(exit()));
    connect(ui->translateButton,SIGNAL(clicked()),this,SLOT(translate()));
    connect(ui->sourceTextEdit,SIGNAL(returnPressed()),this,SLOT(translate()));
    connect(ui->swapButton,SIGNAL(clicked()),this,SLOT(swapLangages()));

    connect(ui->actionCopy,SIGNAL(triggered()),this,SLOT(copy()));
    connect(ui->actionCut,SIGNAL(triggered()),this,SLOT(cut()));
    connect(ui->actionPast,SIGNAL(triggered()),this,SLOT(past()));
    connect(ui->actionPreferences,SIGNAL(triggered()),this,SLOT(showPreferences()));
    connect(ui->actionAboutQt,SIGNAL(triggered()),this,SLOT(showAboutQt()));
    connect(ui->actionAbout,SIGNAL(triggered()),this,SLOT(showAbout()));
    connect(ui->actionTTS,SIGNAL(triggered()),this,SLOT(showTextTTS()));


    connect(ui->sourceSoundButton,SIGNAL(clicked()),this,SLOT(textToSpeak()));
    connect(ui->targetSoundButton,SIGNAL(clicked()),this,SLOT(textToSpeak()));


    //    mPropertyAnimation  = new QPropertyAnimation(this, "pos");
    //    mPropertyAnimation->setDuration(800);
    //    mPropertyAnimation->setStartValue(startPos);
    //    mPropertyAnimation->setEndValue(finalPos);


    //load default langage

    QSettings settings;
    QString sourceId = settings.value("source").toString();
    QString targetId = settings.value("target").toString();
    ui->sourceComboBox->setCurrentIndex(mLangageModel->findLangageId(sourceId));
    ui->targetComboBox->setCurrentIndex(mLangageModel->findLangageId(targetId));

}
Пример #3
0
void QMainWidget::createTrayIcon()
{
    QSystemTrayIcon *trayIcon = new QSystemTrayIcon(this);
    QMenu *menu = new QMenu(this);
    QAction *windowAction = new QAction("Controller Window", this);
    QAction *quitAction = new QAction("Shutdown xboxToVJoy", this);
    
    enableAction = new QAction("Disable", this);
    connect(enableAction, SIGNAL(triggered()), this, SLOT(toggleEnabled()));
    
    connect(windowAction, SIGNAL(triggered()), this, SLOT(showControllerWindow()));
    connect(quitAction, SIGNAL(triggered()), qApp, SLOT(quit()));
    
    menu->addAction(windowAction);
    menu->addSeparator();
    menu->addAction(enableAction);
    menu->addSeparator();
    menu->addAction(quitAction);
    trayIcon->setContextMenu(menu);
    
    QIcon icon(":/icons/icon.png");
    trayIcon->setIcon(icon);
    
    trayIcon->show();
}
Пример #4
0
int main(int argc, char *argv[])
{
#ifdef WIN32
	redirectCout();
#endif

    // If there is a set up white list and the
    // user is not in the white list then we need
    // to simply close this program down.  Otherwise
    // show the interface to the user.
    if (doesWhiteListExist())
    {
        cout << "White list exists" << endl;
        if (!isUserInWhiteList())
        {
            cout << getUserName() << " doesn't exist in white list. Program terminating."<< endl;
            exit(0);
            return 0;
        }
        else
        {
            cout << getUserName() << " is in white list."<< endl;
        }
    }
    else
    {
        cout << "White list does not exist." << endl;
    }

	int tray_tries = 30;
	int available;
	StatusUpdate *status;
	QApplication app(argc, argv);
    QSystemTrayIcon *trayIcon;
	QIcon icon(":images/disconnect.svg");
	available = QSystemTrayIcon::isSystemTrayAvailable();
	while(!available)
	{
		sleep(1);
		tray_tries--;
		if(tray_tries <= 0)
		{
			QMessageBox::critical(NULL, QObject::tr("System Tray"), QObject::tr("The system tray is not supported on your system."));
			return -1;
		}
		available = QSystemTrayIcon::isSystemTrayAvailable();
	}
    trayIcon = new QSystemTrayIcon(NULL);
    trayIcon->setIcon(icon);
    trayIcon->show();
    status = new StatusUpdate(trayIcon);
	return app.exec();
}
Пример #5
0
TrayIconManager::TrayIconManager(QMainWindow* p_main)
{
    QMenu *trayMenu = new QMenu(p_main);
    trayMenu->addAction(new QAction("Dodaj wpis...", p_main)); // dummy action
    trayMenu->addSeparator();
    trayMenu->addAction(new QAction("Drukuj...", p_main)); // dummy action
    // set up and show the system tray icon
    QSystemTrayIcon *trayIcon = new QSystemTrayIcon(p_main);
    trayIcon->setIcon(QIcon("heart.ico"));
    trayIcon->setContextMenu(trayMenu);
    trayIcon->show();
}
Пример #6
0
void tst_QSystemTrayIcon::lastWindowClosed()
{
    QSignalSpy spy(qApp, SIGNAL(lastWindowClosed()));
    QWidget window;
    QSystemTrayIcon icon;
    icon.setIcon(QIcon("whatever.png"));
    icon.show();
    window.show();
    QTimer::singleShot(2500, &window, SLOT(close()));
    QTimer::singleShot(20000, qApp, SLOT(quit())); // in case the test fails
    qApp->exec();
    QVERIFY(spy.count() == 1);
}
Пример #7
0
// Testing get/set functions
void tst_QSystemTrayIcon::showMessage()
{
    QSystemTrayIcon icon;
    icon.setIcon(QIcon("icons/icon.png"));

    icon.showMessage("Title", "Messagecontents");
    icon.showMessage("Title", "Messagecontents", QSystemTrayIcon::NoIcon);
    icon.showMessage("Title", "Messagecontents", QSystemTrayIcon::Warning);
    icon.showMessage("Title", "Messagecontents", QSystemTrayIcon::Critical);

    icon.show();
    icon.showMessage("Title", "Messagecontents");
    icon.showMessage("Title", "Messagecontents", QSystemTrayIcon::NoIcon);
    icon.showMessage("Title", "Messagecontents", QSystemTrayIcon::Warning);
    icon.showMessage("Title", "Messagecontents", QSystemTrayIcon::Critical);
}
Пример #8
0
// Testing get/set functions
void tst_QSystemTrayIcon::getSetCheck()
{
    QSystemTrayIcon icon;
    QCOMPARE(true, icon.toolTip().isEmpty());
    icon.setToolTip("testToolTip");
    QCOMPARE(true, "testToolTip" == icon.toolTip());

    QCOMPARE(true, icon.icon().isNull());
    icon.setIcon(QIcon("icons/icon.png"));
    QCOMPARE(false, icon.icon().isNull());

    QMenu menu;
    QCOMPARE(true, icon.contextMenu() == 0);
    icon.setContextMenu(&menu);
    QCOMPARE(false, icon.contextMenu() == 0);
}
Пример #9
0
int main(int argc, char** argv)
{
    QApplication app(argc, argv);
    KAboutData about("kdeconnect-cli",
                     i18n("KDE Connect Indicator"),
                     QStringLiteral(KDECONNECT_VERSION_STRING),
                     i18n("KDE Connect Indicator tool"),
                     KAboutLicense::GPL,
                     i18n("(C) 2016 Aleix Pol Gonzalez"));
    KAboutData::setApplicationData(about);

    DevicesModel model;
    model.setDisplayFilter(DevicesModel::Reachable | DevicesModel::Paired);

    QMenu menu;
    auto configure = menu.addAction(i18n("Configure..."));
    QObject::connect(configure, &QAction::triggered, configure, [](){
        QProcess::startDetached("kcmshell5", {"kdeconnect"});
    });

    QSystemTrayIcon systray;
    systray.setIcon(QIcon::fromTheme("kdeconnect"));
    systray.setContextMenu(&menu);
    systray.setVisible(true);

    QObject::connect(&model, &DevicesModel::rowsInserted, &model, [&menu, &model](const QModelIndex& /*parent*/, int first, int last) {
        for (int i=first; i<=last; ++i) {
            DeviceDbusInterface* device = model.getDevice(i);
            auto indicator = new DeviceIndicator(device);
            QObject::connect(device, &DeviceDbusInterface::destroyed, indicator, &QObject::deleteLater);

            menu.addMenu(indicator);
        }
    });

    QObject::connect(&model, &DevicesModel::rowsChanged, &model, [&systray, &model]() {
        systray.setToolTip(i18np("%1 device connected", "%1 devices connected", model.rowCount()));
    });

    return app.exec();
}
Пример #10
0
Файл: main.cpp Проект: Abbath/P
/*!
 * \brief main
 * \param argc
 * \param argv
 * \return 
 */
int main(int argc, char* argv[])
{
    QApplication a(argc, argv);
    
    a.setQuitOnLastWindowClosed(false);
    a.processEvents();
    
    Dialog *d = new Dialog;
    d->setWindowIcon(QIcon(":/ops.png"));
    d->show();
    
    QSystemTrayIcon * qsti = new QSystemTrayIcon(d);
    QMenu *trayIconMenu;
    QAction *minimizeAction;
    QAction *restoreAction;
    QAction *quitAction;
    
    minimizeAction = new QAction("Minimize", d);
    restoreAction = new QAction("Restore", d);
    quitAction = new QAction("Quit", d);
    
    QObject::connect(minimizeAction, SIGNAL(triggered()), d, SLOT(hide()));
    QObject::connect(restoreAction, SIGNAL(triggered()), d,SLOT(showNormal()));
    QObject::connect(quitAction, SIGNAL(triggered()), &a, SLOT(quit()));
    QObject::connect(d, SIGNAL(destroyed()), &a, SLOT(quit()));
    
    trayIconMenu = new QMenu(d);
    trayIconMenu->addAction (minimizeAction);
    trayIconMenu->addAction (restoreAction);
    trayIconMenu->addAction (quitAction);
    
    qsti->setContextMenu(trayIconMenu);
    qsti->setIcon(QIcon(":/ops.png"));
    qsti->show();
    
    QObject::connect(qsti, SIGNAL(activated(QSystemTrayIcon::ActivationReason)), d, SLOT(trayHandle(QSystemTrayIcon::ActivationReason)));
    
    return a.exec();
}
Пример #11
0
void TrayPrivate::refreshIcon()
{
    //Note: the icons::getIcon chooses the right icon from list of possible candidates
    // -> we need to refresh the icon in case of icon theme change
    mTrayIcon.setIcon(icons::getIcon(mIconCurrent));
}
Пример #12
0
int main(int argc, char *argv[])
{
    QApplication app(argc, argv);

    const QString app_name("timecop");
    const QString app_version("1.1");
    const QString app_settings_dir(QDir::home().filePath(".timecop"));

    app.setOrganizationName("Daimler AG RD-DDA");
    app.setApplicationName(app_name);

    QSettings::setDefaultFormat(QSettings::IniFormat);
    QSettings::setPath(QSettings::IniFormat,
                       QSettings::UserScope,
                       app_settings_dir);

    QQmlApplicationEngine engine;
    engine.load(QUrl(QStringLiteral("qrc:/main.qml")));

    QObject *root = 0;
    QWidget *rootWindow = 0;
    SystrayHelper systrayHelper;
    engine.rootContext()->setContextProperty("systrayHelper", &systrayHelper);

    engine.rootContext()->setContextProperty("app_name",  app_name);
    engine.rootContext()->setContextProperty("app_version",  app_version);
    engine.rootContext()->setContextProperty("app_settings_dir",  app_settings_dir);


    if (engine.rootObjects().size() > 0)
    {
        root = engine.rootObjects().at(0);
        systrayHelper.setRootWindow(root);
        if(root->isWindowType()){
            rootWindow = qobject_cast<QWidget*>(root);

            QApplication::setQuitOnLastWindowClosed(false);

            QAction *minimizeAction = new QAction(QObject::tr("Mi&nimize"), rootWindow);
            rootWindow->connect(minimizeAction, SIGNAL(triggered()), root, SLOT(hide()));
            QAction *maximizeAction = new QAction(QObject::tr("Ma&ximize"), rootWindow);
            rootWindow->connect(maximizeAction, SIGNAL(triggered()), root, SLOT(showMaximized()));
            QAction *restoreAction = new QAction(QObject::tr("&Restore"), rootWindow);
            rootWindow->connect(restoreAction, SIGNAL(triggered()), root, SLOT(showNormal()));
            QAction *quitAction = new QAction(QObject::tr("&Quit"), rootWindow);
            rootWindow->connect(quitAction, SIGNAL(triggered()), qApp, SLOT(quit()));

            QMenu *trayIconMenu = new QMenu(rootWindow);
            trayIconMenu->addAction(minimizeAction);
            trayIconMenu->addAction(maximizeAction);
            trayIconMenu->addAction(restoreAction);
            trayIconMenu->addSeparator();
            trayIconMenu->addAction(quitAction);

            QSystemTrayIcon *trayIcon = new QSystemTrayIcon(rootWindow);
            QIcon icon(":/trayicon.png");
            icon.setIsMask(true);
            //trayIcon->setContextMenu(trayIconMenu);
            trayIcon->setIcon(icon);
            trayIcon->setToolTip("Click to open");
            trayIcon->setVisible(true);
            systrayHelper.setTrayIcon(trayIcon);
            QObject::connect(trayIcon, SIGNAL(activated(QSystemTrayIcon::ActivationReason)), &systrayHelper, SLOT(activatedSystray(QSystemTrayIcon::ActivationReason)));

            trayIcon->show();
        }

    }

    return app.exec();
}
Пример #13
0
	inline void CNotificationManager::updateDeviceIcon(CUIDevice * uiDevice) {
		QSystemTrayIcon * trayIcon = m_UIDeviceIcons[uiDevice];
		trayIcon->setToolTip(shortSummary(uiDevice->device()));
		trayIcon->setIcon(QIcon(iconFile(uiDevice->device())));
	}
Пример #14
0
MainForm::MainForm(QWidget *parent) : QMainWindow(parent) {
    ui.setupUi(this);
    setWindowIcon(QIcon(":/icons/logo.ico"));

    log = findChild<LogWidget *>("log");

    qInstallMessageHandler(messageHandler);

    // Switch to correct tab
    tabs = findChild<QTabWidget *>("tabs");
    tabs->setCurrentIndex(Tabs::GRABBER);
    tabs->tabBar()->setTabEnabled(Tabs::STREAM, false);
    connect(tabs, &QTabWidget::currentChanged, this, &MainForm::trySaveSettings);
    tabs->tabBar()->setExpanding(true);

    // Connect start button
    start_button = findChild<QPushButton *>("start");
    start_button->setObjectName("no_disable");
    connect(start_button, &QPushButton::clicked, this, &MainForm::startStream);

    stop_button = findChild<QPushButton *>("stop");
    stop_button->setObjectName("no_disable");
    connect(stop_button, &QPushButton::clicked, this, &MainForm::completeStream);

    QPushButton *add = findChild<QPushButton *>("add");
    connect(add, &QPushButton::clicked, this, &MainForm::setPlaylist);

    start_button->setHidden(false);
    stop_button->setHidden(true);

    progress = findChild<QProgressBar *>("progress");

    // Connect donation button
    QPushButton *donate_button = findChild<QPushButton *>("donate");
    connect(donate_button, &QPushButton::clicked, this, &MainForm::donateMessage);

    // Setup table
    links = findChild<LinkWidget *>("links");
    links->header()->resizeSection(Columns::NAME, width() / 2);
    links->header()->resizeSection(Columns::SIZE, width() / 4);

    play_list = findChild<QListWidget *>("play_list");

    QPushButton *open_container = findChild<QPushButton *>("open_container");
    connect(open_container, SIGNAL(clicked()), this, SLOT(openDLC()));

    QPushButton *text = findChild<QPushButton *>("text");
    connect(text, &QPushButton::clicked, this, &MainForm::openLinkInput);

    QPushButton *about = findChild<QPushButton *>("about");
    connect(about, &QPushButton::clicked, this, &MainForm::showAbout);

    clicknload_switch = findChild<QCheckBox *>("clicknload_switch");
    connect(clicknload_switch, &QCheckBox::clicked, this, &MainForm::switchClickNLoad);

    QSystemTrayIcon *trayIcon = new QSystemTrayIcon(this);;
    trayIcon->setIcon(this->windowIcon());
    trayIcon->show();
//    connect(trayIcon, SIGNAL(messageClicked()), this, SLOT(messageClicked()));
    connect(trayIcon, SIGNAL(activated(QSystemTrayIcon::ActivationReason)),
            this, SLOT(iconActivated(QSystemTrayIcon::ActivationReason)));

    // Setup settings
    QTabWidget *settings_tabs = findChild<QTabWidget *>("settings_tabs");
    settings_tabs->setCurrentIndex(Tabs::STREAM);
    // Setup highlighter
    mpv_settings = findChild<QPlainTextEdit *>("mpv_settings");
    new Highlighter(mpv_settings->document());

    archive_directory = findChild<FilePickerWidget *>("archive_directory");
    download_directory = findChild<FilePickerWidget *>("download_directory");

    edit_memory = findChild<QDoubleSpinBox *>("edit_memory");
    edit_down_speed = findChild<QDoubleSpinBox *>("edit_down_speed");

    combo_hoster = findChild<QComboBox *>("combo_hoster");
    combo_hoster->addItem("uploaded.to");
    edit_password = findChild<QLineEdit *>("edit_password");
    edit_username = findChild<QLineEdit *>("edit_username");

    if (load_settings()) {
        std::list<std::string> demo{"http://ul.to/a2os4kd5", "http://ul.to/ev8156dc"};
        links->appendLinks("demo", demo);
    } else {
        links->load();
    }
    server = std::make_shared<clicknload::Server>(
            [this](std::string name, std::list<std::string> urls) { clicknload_background(name, urls); });
    switchClickNLoad(true);


    connect(this, &MainForm::linksAdded, this, &MainForm::activlyAppendLinks);

    links->startAggregator(options);
}