Example #1
0
// Event handling
bool LightscreenWindow::event(QEvent *event)
{
    if (event->type() == QEvent::Show) {
        QPoint savedPosition = settings()->value("position").toPoint();

        if (!savedPosition.isNull() && qApp->desktop()->availableGeometry().contains(QRect(savedPosition, size()))) {
            move(savedPosition);
        }

        if (mHasTaskbarButton) {
            mTaskbarButton->setWindow(windowHandle());
        }
    } else if (event->type() == QEvent::Hide) {
        settings()->setValue("position", pos());
    } else if (event->type() == QEvent::Close) {
        if (settings()->value("options/tray").toBool() && settings()->value("options/closeHide").toBool()) {
            closeToTrayWarning();
            hide();
        } else if (settings()->value("options/closeHide").toBool()) {
            if (closingWithoutTray()) {
                hide();
            }
        } else {
            quit();
        }
    } else if (event->type() == QEvent::KeyPress) {
        QKeyEvent *keyEvent = static_cast<QKeyEvent *>(event);
#ifdef Q_WS_MAC
        if (keyEvent->modifiers() == Qt::ControlModifier && e->key() == Qt::Key_Period) {
            keyEvent->ignore();

            if (isVisible()) {
                toggleVisibility();
            }

            return false;
        } else
#endif
            if (!keyEvent->modifiers() && keyEvent->key() == Qt::Key_Escape) {
                keyEvent->ignore();

                if (isVisible()) {
                    toggleVisibility();
                }

                return false;
            }
    } else if (event->type() == QEvent::LanguageChange) {
        ui.retranslateUi(this);
        resize(minimumSizeHint());
    }


    return QMainWindow::event(event);
}
Example #2
0
MainWindow::MainWindow(QWidget* parent, Qt::WindowFlags flags)
	: QMainWindow(parent, flags)
{
	ui.setupUi(this);
	createProgressBar();
	ui.tabWidget->setTabContextMenuPolicy(Qt::ActionsContextMenu);

	connect(ui.actionQuit, SIGNAL(triggered()), this, SLOT(close()));
	connect(ui.actionAddTab, SIGNAL(triggered()), this, SLOT(addTab()));
	connect(ui.actionAboutQt, SIGNAL(triggered()), qApp, SLOT(aboutQt()));
	connect(ui.actionAboutQxtGui, SIGNAL(triggered()), this, SLOT(aboutQxtGui()));
	connect(ui.actionSwitchLayoutDirection, SIGNAL(triggered()), this, SLOT(switchLayoutDirection()));
	connect(ui.actionConfigure, SIGNAL(triggered()), this, SLOT(configure()));

    QxtGlobalShortcut* shortcut = new QxtGlobalShortcut(this);
    connect(shortcut, SIGNAL(activated()), this, SLOT(toggleVisibility()));
    QKeySequence key("Ctrl+Shift+Alt+S");
    if (shortcut->setShortcut(key))
        ui.labelVisibility->setText(ui.labelVisibility->text().arg(key.toString(QKeySequence::NativeText)));
    else
        ui.labelVisibility->hide();

    QTimer* timer = new QTimer(this);
    connect(timer, SIGNAL(timeout()), this, SLOT(updateIdleTime()));
    timer->start(150);
    updateIdleTime();
}
Example #3
0
void MyGLWidget::addActions(QToolBar* menu) {
    QAction * actionUndo = new QAction("Undo", menu);
    menu->addAction(actionUndo);
    connect(actionUndo,SIGNAL(triggered()), this, SLOT(undo()));

    if (scene->activeNode) {
        QAction * actionVisible = new QAction("Visible", menu);
        actionVisible->setCheckable(true);
        actionVisible->setChecked(scene->activeNode->visible);
        menu->addAction(actionVisible);
        connect(actionVisible,SIGNAL(triggered()), this, SLOT(toggleVisibility()));

        QAction * actionColor = new QAction("Color", menu);
        menu->addAction(actionColor);
        connect(actionColor,SIGNAL(triggered()), this, SLOT(setColor()));

    }

    menu->addSeparator();

    SurfaceNode * sn = qobject_cast<SurfaceNode*>(scene->activeNode);

    if (sn||scene->editLayerNo != -1) {
        QAction * editLayer = new QAction(QString("Editing"), menu);
        editLayer->setCheckable(true);
        editLayer->setChecked(scene->editLayerNo != -1);
        connect(editLayer, SIGNAL(triggered()), this, SLOT(editLayer()));
        menu->addAction(editLayer);
    } else {
        BoxNode * bn = qobject_cast<BoxNode*>(scene->activeNode);
        if (bn) {
            QAction * showSea = new QAction(QString("Change Sea"), menu);
            showSea->setCheckable(true);
            showSea->setChecked(scene->setSeaLevel);
            connect(showSea, SIGNAL(toggled(bool)), this, SLOT(seaLevel()));
            menu->addAction(showSea);
        } else {
            RiverNode * rn =  qobject_cast<RiverNode*>(scene->activeNode);

            if (rn) {
                QAction * deposit = new QAction(QString("New Deposit"), menu);
                connect(deposit, SIGNAL(triggered()), this, SLOT(createDeposits()));
                menu->addAction(deposit);

                if (deposit) {
                    QAction * stop = new QAction(QString("Stop/start Deposit"), menu);
                    connect(stop, SIGNAL(triggered()), rn, SLOT(stopDeposit()));
                    menu->addAction(stop);
                }

            }

        }
    }
void Window::iconActivated(QSystemTrayIcon::ActivationReason reason)
{
    switch (reason) {
    case QSystemTrayIcon::Trigger:
    case QSystemTrayIcon::DoubleClick:
    case QSystemTrayIcon::MiddleClick:
        toggleVisibility();
        break;
    default:
        ;
    }
}
void KisPerspectiveGridManager::setup(KActionCollection * collection)
{
    m_toggleGrid  = new KToggleAction(i18n("Show Perspective Grid"), this);
    collection->addAction("view_toggle_perspective_grid", m_toggleGrid);
    connect(m_toggleGrid, SIGNAL(triggered()), this, SLOT(toggleVisibility()));

    m_toggleGrid->setCheckedState(KGuiItem(i18n("Hide Perspective Grid")));
    m_toggleGrid->setChecked(false);
    m_gridClear  = new KAction(i18n("Clear Perspective Grid"), this);
    collection->addAction("view_clear_perspective_grid", m_gridClear);
    connect(m_gridClear, SIGNAL(triggered()), this, SLOT(clearPerspectiveGrid()));
}
Example #6
0
	void Widget::runCommand(const std::string &command, const std::string &args)
	{
		if(command == "show_" + mCommandSuffix)
		{
			show();
		}
		else if(command == "hide_" + mCommandSuffix)
		{
			hide();
		}
		else if(command == "toggleVisibility_" + mCommandSuffix)
		{
			toggleVisibility();
		}
	}
bool LayerListDelegate::editorEvent(QEvent *event, QAbstractItemModel *model, const QStyleOptionViewItem &option, const QModelIndex &index)
{
	if(event->type() == QEvent::MouseButtonRelease) {
		const canvas::LayerListItem &layer = index.data().value<canvas::LayerListItem>();
		const QMouseEvent *me = static_cast<QMouseEvent*>(event);

		if(me->button() == Qt::LeftButton) {
			if(me->x() < 24) {
				// Clicked on opacity glyph: toggle visibility
				emit toggleVisibility(layer.id, layer.hidden);
			}
		}
	}

	return QItemDelegate::editorEvent(event, model, option, index);
}
	static void toggleVisibility(View *view)
	{
		toggleVisibility(view->getSearchName());
	}
Example #9
0
PinEntryDialog::PinEntryDialog(QWidget *parent, const char *name,
                               int timeout, bool modal, bool enable_quality_bar,
                               const QString &repeatString,
                               const QString &visibilityTT,
                               const QString &hideTT)
    : QDialog(parent, Qt::WindowStaysOnTopHint),
      mRepeat(NULL),
      _grabbed(false),
      mVisibilityTT(visibilityTT),
      mHideTT(hideTT),
      mVisiActionEdit(NULL),
      mVisiCB(NULL)
{
    setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);

    if (modal) {
        setWindowModality(Qt::ApplicationModal);
    }

    _icon = new QLabel(this);
    _icon->setPixmap(icon());

    _error = new QLabel(this);
    _error->setWordWrap(true);
    QPalette pal;
    pal.setColor(QPalette::WindowText, Qt::red);
    _error->setPalette(pal);
    _error->hide();

    _desc = new QLabel(this);
    _desc->setWordWrap(true);
    _desc->hide();

    _prompt = new QLabel(this);
    _prompt->hide();

    _edit = new QLineEdit(this);
    _edit->setMaxLength(256);
    _edit->setEchoMode(QLineEdit::Password);

    _prompt->setBuddy(_edit);

    if (enable_quality_bar) {
        _quality_bar_label = new QLabel(this);
        _quality_bar_label->setAlignment(Qt::AlignVCenter);
        _quality_bar = new QProgressBar(this);
        _quality_bar->setAlignment(Qt::AlignCenter);
        _have_quality_bar = true;
    } else {
        _have_quality_bar = false;
    }

    QDialogButtonBox *const buttons = new QDialogButtonBox(this);
    buttons->setStandardButtons(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
    _ok = buttons->button(QDialogButtonBox::Ok);
    _cancel = buttons->button(QDialogButtonBox::Cancel);

    _ok->setDefault(true);

    if (style()->styleHint(QStyle::SH_DialogButtonBox_ButtonsHaveIcons)) {
        _ok->setIcon(style()->standardIcon(QStyle::SP_DialogOkButton));
        _cancel->setIcon(style()->standardIcon(QStyle::SP_DialogCancelButton));
    }

    if (timeout > 0) {
        _timer = new QTimer(this);
        connect(_timer, SIGNAL(timeout()), this, SLOT(slotTimeout()));
        _timer->start(timeout * 1000);
    } else {
        _timer = NULL;
    }

    connect(buttons, SIGNAL(accepted()), this, SLOT(accept()));
    connect(buttons, SIGNAL(rejected()), this, SLOT(reject()));
    connect(_edit, SIGNAL(textChanged(QString)),
            this, SLOT(updateQuality(QString)));
    connect(_edit, SIGNAL(textChanged(QString)),
            this, SLOT(textChanged(QString)));

    _edit->setFocus();

    QGridLayout *const grid = new QGridLayout(this);
    int row = 1;
    grid->addWidget(_error, row++, 1, 1, 2);
    grid->addWidget(_desc,  row++, 1, 1, 2);
    //grid->addItem( new QSpacerItem( 0, _edit->height() / 10, QSizePolicy::Minimum, QSizePolicy::Fixed ), 1, 1 );
    grid->addWidget(_prompt, row, 1);
    grid->addWidget(_edit, row++, 2);
    if (!repeatString.isNull()) {
        mRepeat = new QLineEdit;
        mRepeat->setMaxLength(256);
        mRepeat->setEchoMode(QLineEdit::Password);
        connect(mRepeat, SIGNAL(textChanged(QString)),
                this, SLOT(textChanged(QString)));
        QLabel *repeatLabel = new QLabel(repeatString);
        repeatLabel->setBuddy(mRepeat);
        grid->addWidget(repeatLabel, row, 1);
        grid->addWidget(mRepeat, row++, 2);
        setTabOrder(_edit, mRepeat);
        setTabOrder(mRepeat, _ok);
    }
    if (enable_quality_bar) {
        grid->addWidget(_quality_bar_label, row, 1);
        grid->addWidget(_quality_bar, row++, 2);
    }
    /* Set up the show password action */
    const QIcon visibilityIcon = QIcon::fromTheme(QLatin1String("visibility"));
    const QIcon hideIcon = QIcon::fromTheme(QLatin1String("hint"));
#if QT_VERSION >= 0x050200
    if (!visibilityIcon.isNull() && !hideIcon.isNull()) {
        mVisiActionEdit = _edit->addAction(visibilityIcon, QLineEdit::TrailingPosition);
        mVisiActionEdit->setVisible(false);
        mVisiActionEdit->setToolTip(mVisibilityTT);
        connect(mVisiActionEdit, SIGNAL(triggered()), this, SLOT(toggleVisibility()));
    } else
#endif
    {
        if (!mVisibilityTT.isNull()) {
            mVisiCB = new QCheckBox(mVisibilityTT);
            connect(mVisiCB, SIGNAL(toggled(bool)), this, SLOT(toggleVisibility()));
            grid->addWidget(mVisiCB, row++, 1, 1, 2, Qt::AlignLeft);
        }
    }
/** Creates a tray icon with a context menu and adds it to the system
 * notification area. */
void MainWindow::createTrayIcon()
{
    /** Tray icon Menu **/
    QMenu *trayMenu = new QMenu(this);
    if (sysTrayStatus) sysTrayStatus->trayMenu = trayMenu;
    QObject::connect(trayMenu, SIGNAL(aboutToShow()), this, SLOT(updateMenu()));
    toggleVisibilityAction = trayMenu->addAction(QIcon(IMAGE_RETROSHARE), tr("Show/Hide"), this, SLOT(toggleVisibilitycontextmenu()));
    if (sysTrayStatus) sysTrayStatus->toggleVisibilityAction = toggleVisibilityAction;

    /* Create status menu */
    QMenu *statusMenu = trayMenu->addMenu(tr("Status"));
    initializeStatusObject(statusMenu, true);

    /* Create notify menu */
    notifyMenu = trayMenu->addMenu(tr("Notify"));
    notifyMenu->menuAction()->setVisible(false);

    trayMenu->addSeparator();
    trayMenu->addAction(QIcon(IMAGE_MESSENGER), tr("Open Messenger"), this, SLOT(showMessengerWindow()));
    trayMenu->addAction(QIcon(IMAGE_MESSAGES), tr("Open Messages"), this, SLOT(showMess()));
    trayMenu->addAction(QIcon(":/images/emblem-web.png"), tr("Show web interface"), this, SLOT(showWebinterface()));
    trayMenu->addAction(QIcon(IMAGE_BWGRAPH), tr("Bandwidth Graph"), _bandwidthGraph, SLOT(showWindow()));
    trayMenu->addAction(QIcon(IMAGE_DHT), tr("Statistics"), this, SLOT(showStatisticsWindow()));


#ifdef UNFINISHED
    trayMenu->addAction(QIcon(IMAGE_UNFINISHED), tr("Applications"), this, SLOT(showApplWindow()));
#endif
    trayMenu->addAction(QIcon(IMAGE_PREFERENCES), tr("Options"), this, SLOT(showSettings()));
    trayMenu->addAction(QIcon(IMG_HELP), tr("Help"), this, SLOT(showHelpDialog()));
    trayMenu->addSeparator();
    trayMenu->addAction(QIcon(IMAGE_MINIMIZE), tr("Minimize"), this, SLOT(showMinimized()));
    trayMenu->addAction(QIcon(IMAGE_MAXIMIZE), tr("Maximize"), this, SLOT(showMaximized()));
    trayMenu->addSeparator();
    trayMenu->addAction(QIcon(IMAGE_CLOSE), tr("&Quit"), this, SLOT(doQuit()));
    /** End of Icon Menu **/

    // Create the tray icon
    trayIcon = new QSystemTrayIcon(this);
    trayIcon->setToolTip(tr("RetroShare"));
    trayIcon->setContextMenu(trayMenu);
    trayIcon->setIcon(QIcon(IMAGE_NOONLINE));

    connect(trayIcon, SIGNAL(activated(QSystemTrayIcon::ActivationReason)), this, SLOT(toggleVisibility(QSystemTrayIcon::ActivationReason)));
    trayIcon->show();
}
Example #11
0
TimerManager::TimerManager(Stack* documents, QWidget* parent)
	: QDialog(parent, Qt::WindowTitleHint | Qt::WindowSystemMenuHint | Qt::WindowCloseButtonHint),
	m_documents(documents)
{
	setWindowTitle(tr("Timers"));

	// Set up interaction with timer display
	m_display = new TimerDisplay(m_timers, this);
	m_display->setContextMenuPolicy(Qt::CustomContextMenu);
	connect(m_display, SIGNAL(clicked()), this, SLOT(toggleVisibility()));
	connect(m_display, SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(recentTimerMenuRequested(const QPoint&)));

	// Create clock
	m_clock_label = new QLabel(this);
	m_clock_label->setAlignment(Qt::AlignCenter);

	m_clock_timer = new QTimer(this);
	m_clock_timer->setInterval(1000);
	connect(m_clock_timer, SIGNAL(timeout()), this, SLOT(updateClock()));
	startClock();

	// Create timers layout
	QWidget* timers_widget = new QWidget(this);

	m_timers_layout = new QVBoxLayout(timers_widget);
	m_timers_layout->addStretch();
	m_timers_layout->setSizeConstraint(QLayout::SetMinAndMaxSize);

	m_timers_area = new QScrollArea(this);
	m_timers_area->setWidget(timers_widget);
	m_timers_area->setWidgetResizable(true);

	// Create action buttons
	QDialogButtonBox* buttons = new QDialogButtonBox(QDialogButtonBox::Close, Qt::Horizontal, this);
	connect(buttons, SIGNAL(rejected()), this, SLOT(close()));

	m_new_button = buttons->addButton(tr("New"), QDialogButtonBox::ActionRole);
	m_new_button->setDefault(true);
	connect(m_new_button, SIGNAL(clicked()), this, SLOT(newTimer()));

	m_recent_timers = new QMenu(this);
	m_recent_button = buttons->addButton(tr("Recent"), QDialogButtonBox::ActionRole);
	m_recent_button->setMenu(m_recent_timers);
	setupRecentMenu();
	connect(m_recent_timers, SIGNAL(triggered(QAction*)), this, SLOT(recentTimer(QAction*)));

	// Lay out window
	QVBoxLayout* layout = new QVBoxLayout(this);
	layout->addWidget(m_clock_label);
	layout->addWidget(m_timers_area, 1);
	layout->addWidget(buttons);
	setMinimumHeight(sizeHint().width());

	QSettings settings;
	settings.beginGroup("Timers");
	resize(settings.value("DialogSize").toSize());

	// Load currently running timers
	QStringList ids = settings.childKeys();
	foreach (const QString& id, ids) {
		int i = id.mid(5).toInt();
		if (!id.startsWith("Timer") || i == 0) {
			continue;
		}
		Timer* timer = new Timer(id, m_documents, this);
		addTimer(timer);
		timerChanged(timer);
	}
Example #12
0
/** Constructor */
MainWindow::MainWindow(QWidget* parent, Qt::WFlags flags)
    : RWindow("MainWindow", parent, flags)
{
    /* Invoke the Qt Designer generated QObject setup routine */
    ui.setupUi(this);
    
    /* Create RshareSettings object */
    _settings = new RshareSettings();
    
    setWindowTitle(tr("RetroShare %1 a secure decentralised commmunication platform").arg(retroshareVersion())); 

    mSMPlayer = NULL;
  	
    // Setting icons
    this->setWindowIcon(QIcon(QString::fromUtf8(":/images/rstray3.png")));
    
    /* Create all the dialogs of which we only want one instance */
    _bandwidthGraph = new BandwidthGraph();
    messengerWindow = new MessengerWindow();
    _preferencesWindow = new PreferencesWindow();
    applicationWindow = new ApplicationWindow();
    applicationWindow->hide();
	
    /** Left Side ToolBar**/
    connect(ui.actionAdd_Friend, SIGNAL(triggered() ), this , SLOT( addFriend() ) );
    connect(ui.actionAdd_Share, SIGNAL(triggered() ), this , SLOT( openShareManager() ) );
    connect(ui.actionOptions, SIGNAL(triggered()), this, SLOT( showPreferencesWindow()) );
    connect(ui.actionMessenger, SIGNAL(triggered()), this, SLOT( showMessengerWindow()) );
    connect(ui.actionSMPlayer, SIGNAL(triggered()), this, SLOT( showsmplayer()) );
    connect(ui.actionAbout, SIGNAL(triggered()), this, SLOT( showabout()) );
    connect(ui.actionColor, SIGNAL(triggered()), this, SLOT( setStyle()) );
    //connect(ui.actionSettings, SIGNAL(triggered()), this, SLOT( showSettings()) );
   	 
       
    /** adjusted quit behaviour: trigger a warning that can be switched off in the saved
        config file RetroShare.conf */
    connect(ui.actionQuit, SIGNAL(triggered()), this, SLOT(doQuit()));

    /* load the StyleSheet*/
    loadStyleSheet(Rshare::stylesheet()); 


    /* Create the Main pages and actions */
    QActionGroup *grp = new QActionGroup(this);


    ui.stackPages->add(networkDialog = new NetworkDialog(ui.stackPages),
                       createPageAction(QIcon(IMAGE_NETWORK2), tr("Network"), grp));

  
    ui.stackPages->add(peersDialog = new PeersDialog(ui.stackPages),
                       createPageAction(QIcon(IMAGE_PEERS), tr("Friends"), grp));

    //PeersFeed *peersFeed = NULL;
    //ui.stackPages->add(peersFeed = new PeersFeed(ui.stackPages),
    //		createPageAction(QIcon(IMAGE_PEERS), tr("Peers"), grp));
#ifdef TURTLE_HOPPING
    ui.stackPages->add(turtleDialog = new TurtleSearchDialog(ui.stackPages),
                       createPageAction(QIcon(IMAGE_TURTLE), tr("Turtle"), grp));
#endif
    ui.stackPages->add(searchDialog = new SearchDialog(ui.stackPages),
                       createPageAction(QIcon(IMAGE_SEARCH), tr("Search"), grp));
                     
    ui.stackPages->add(transfersDialog = new TransfersDialog(ui.stackPages),
                      createPageAction(QIcon(IMAGE_TRANSFERS), tr("Transfers"), grp));
                     
    //TransferFeed *transferFeed = NULL;
    //ui.stackPages->add(transferFeed = new TransferFeed(ui.stackPages),
    //		createPageAction(QIcon(IMAGE_LINKS), tr("Transfers"), grp));
	
    ui.stackPages->add(sharedfilesDialog = new SharedFilesDialog(ui.stackPages),
                       createPageAction(QIcon(IMAGE_FILES), tr("Files"), grp));                     

    //MsgFeed *msgFeed = NULL;
    //ui.stackPages->add(msgFeed = new MsgFeed(ui.stackPages),
    //		createPageAction(QIcon(IMAGE_MESSAGES), tr("Messages"), grp));

    ui.stackPages->add(messagesDialog = new MessagesDialog(ui.stackPages),
                      createPageAction(QIcon(IMAGE_MESSAGES), tr("Messages"), grp));
                       
    LinksDialog *linksDialog = NULL;


#ifdef RS_RELEASE_VERSION    
    channelsDialog = NULL;
    ui.stackPages->add(linksDialog = new LinksDialog(ui.stackPages),
			createPageAction(QIcon(IMAGE_LINKS), tr("Links Cloud"), grp));

    ForumsDialog *forumsDialog = NULL;
    ui.stackPages->add(forumsDialog = new ForumsDialog(ui.stackPages),
                       createPageAction(QIcon(IMAGE_FORUMS), tr("Forums"), grp));

	
#else
    channelsDialog = NULL;
    ui.stackPages->add(linksDialog = new LinksDialog(ui.stackPages),
			createPageAction(QIcon(IMAGE_LINKS), tr("Links Cloud"), grp));

    ChannelFeed *channelFeed = NULL;
    ui.stackPages->add(channelFeed = new ChannelFeed(ui.stackPages),
                      createPageAction(QIcon(IMAGE_CHANNELS), tr("Channels"), grp));

    ForumsDialog *forumsDialog = NULL;
    ui.stackPages->add(forumsDialog = new ForumsDialog(ui.stackPages),
                       createPageAction(QIcon(IMAGE_FORUMS), tr("Forums"), grp));
                       
#endif
    NewsFeed *newsFeed = NULL;
    ui.stackPages->add(newsFeed = new NewsFeed(ui.stackPages),
		createPageAction(QIcon(IMAGE_NEWSFEED), tr("News Feed"), grp));

#ifdef PLUGINMGR
    ui.stackPages->add(pluginsPage = new PluginsPage(ui.stackPages),
                       createPageAction(QIcon(IMAGE_PLUGINS), tr("Plugins"), grp));
#endif

    /* Create the toolbar */
    ui.toolBar->addActions(grp->actions());
    ui.toolBar->addSeparator();
    connect(grp, SIGNAL(triggered(QAction *)), ui.stackPages, SLOT(showPage(QAction *)));

#ifdef RS_RELEASE_VERSION    
#else   
    addAction(new QAction(QIcon(IMAGE_UNFINISHED), tr("Unfinished"), ui.toolBar), SLOT(showApplWindow()));                   
#endif
       
    /* Select the first action */
    grp->actions()[0]->setChecked(true);
    
    /* also an empty list of chat windows */
    messengerWindow->setChatDialog(peersDialog);

    // Allow to play files from SharedFilesDialog.
    connect(sharedfilesDialog, SIGNAL(playFiles( QStringList )), this, SLOT(playFiles( QStringList )));
    connect(transfersDialog, SIGNAL(playFiles( QStringList )), this, SLOT(playFiles( QStringList )));

    /** StatusBar section **/
    peerstatus = new PeerStatus();
    statusBar()->addWidget(peerstatus);
    
    dhtstatus = new DHTStatus();
    statusBar()->addWidget(dhtstatus);
    
    natstatus = new NATStatus();
    statusBar()->addWidget(natstatus);

	  QWidget *widget = new QWidget();
    QSizePolicy sizePolicy(QSizePolicy::Maximum, QSizePolicy::Preferred);
    sizePolicy.setHorizontalStretch(0);
    sizePolicy.setVerticalStretch(0);
    sizePolicy.setHeightForWidth(widget->sizePolicy().hasHeightForWidth());
    widget->setSizePolicy(sizePolicy);
    QHBoxLayout *horizontalLayout = new QHBoxLayout(widget);
	  horizontalLayout->setContentsMargins(0, 0, 0, 0);
    horizontalLayout->setObjectName(QString::fromUtf8("horizontalLayout"));
	  _hashing_info_label = new QLabel(widget) ;
    _hashing_info_label->setObjectName(QString::fromUtf8("label"));

    horizontalLayout->addWidget(_hashing_info_label);
    QSpacerItem *horizontalSpacer = new QSpacerItem(1000, 0, QSizePolicy::Expanding, QSizePolicy::Minimum);
    horizontalLayout->addItem(horizontalSpacer);

    statusBar()->addPermanentWidget(widget);
	  _hashing_info_label->hide() ;

    ratesstatus = new RatesStatus();
    statusBar()->addPermanentWidget(ratesstatus);
    /******* Status Bar end ******/
  
    /* Create the actions that will go in the tray menu */
    createActions();
             
/******  
    * This is an annoying warning I get all the time...
    * (no help!)
    *
    *
    if (!QSystemTrayIcon::isSystemTrayAvailable())
    QMessageBox::warning(0, tr("System tray is unavailable"),
    tr("System tray unavailable"));
******/

    // Tray icon Menu
    menu = new QMenu(this);
    QObject::connect(menu, SIGNAL(aboutToShow()), this, SLOT(updateMenu()));
    toggleVisibilityAction = 
            menu->addAction(QIcon(IMAGE_RETROSHARE), tr("Show/Hide"), this, SLOT(toggleVisibilitycontextmenu()));
    menu->addSeparator();
    menu->addAction(_messengerwindowAct);
    menu->addAction(_messagesAct);
    menu->addAction(_bandwidthAct);

    /* bandwidth only in development version */
#ifdef RS_RELEASE_VERSION    
#else
    menu->addAction(_appAct);
#endif
    menu->addAction(_prefsAct);
    //menu->addAction(_smplayerAct);
    menu->addAction(_helpAct);
    menu->addSeparator();
    menu->addAction(QIcon(IMAGE_MINIMIZE), tr("Minimize"), this, SLOT(showMinimized()));
    menu->addAction(QIcon(IMAGE_MAXIMIZE), tr("Maximize"), this, SLOT(showMaximized()));
    menu->addSeparator();
    menu->addAction(QIcon(IMAGE_CLOSE), tr("&Quit"), this, SLOT(doQuit()));
    // End of Icon Menu
    
    // Create the tray icon
    trayIcon = new QSystemTrayIcon(this);
    trayIcon->setToolTip(tr("RetroShare"));
    trayIcon->setContextMenu(menu);
    trayIcon->setIcon(QIcon(IMAGE_RETROSHARE));
    
    connect(trayIcon, SIGNAL(activated(QSystemTrayIcon::ActivationReason)), this, 
            SLOT(toggleVisibility(QSystemTrayIcon::ActivationReason)));
    trayIcon->show();

    QTimer *timer = new QTimer(this);
    timer->connect(timer, SIGNAL(timeout()), this, SLOT(updateStatus()));
    timer->start(1000);
}
Example #13
0
Notes::Notes() :
    m_notesFileName(QStandardPaths::standardLocations(QStandardPaths::DataLocation).value(0)),
    m_settings(QApplication::applicationName()),
    m_textEdit(new QPlainTextEdit),
    m_menu(new QMenu(this)),
    m_saveTimer(new QTimer(this)),

    m_canMove(false)
{
    QAction *saveAct = new QAction(tr("Save"), this);
    saveAct->setShortcut(QKeySequence("Ctrl+S"));
    connect(saveAct, &QAction::triggered, this, &Notes::save);

    m_visibilityAct = new QAction(tr("Show"), this);
    m_visibilityAct->setProperty("SecondText", tr("Hide"));
    connect(m_visibilityAct, &QAction::triggered, this, &Notes::toggleVisibility);

    QAction *stayOnBottomAct = new QAction(tr("Stay on bottom"), this);
    stayOnBottomAct->setShortcut(QKeySequence("Alt+B"));
    stayOnBottomAct->setCheckable(true);
    connect(stayOnBottomAct, &QAction::triggered, [this, stayOnBottomAct] {
        Qt::WindowFlags flags = getNotesWindowFlags();
        if (stayOnBottomAct->isChecked())
            flags |= Qt::WindowStaysOnBottomHint;
        setWindowFlags(flags);
        setVisible(m_visible);
    });

    QAction *aboutAct = new QAction(tr("About"), this);
    aboutAct->setShortcut(QKeySequence("F1"));
    connect(aboutAct, &QAction::triggered, [this] {
        QMessageBox::information(this, QString(), tr("KiiroNotes - simple notes for Linux desktop") + " (" + QCoreApplication::applicationVersion() + ")");
    });

    QAction *closeAct = new QAction(tr("Close"), this);
    closeAct->setShortcut(QKeySequence("Ctrl+Q"));
    connect(closeAct, &QAction::triggered, this, &Notes::close);

    /**/

    m_saveTimer->setSingleShot(true);
    connect(m_saveTimer, &QTimer::timeout, this, &Notes::save);

    /**/

    m_menu->addAction(saveAct);
    m_menu->addSeparator();
    m_menu->addAction(m_visibilityAct);
    m_menu->addAction(stayOnBottomAct);
    m_menu->addSeparator();
    m_menu->addAction(aboutAct);
    m_menu->addSeparator();
    m_menu->addAction(closeAct);

    /**/

    m_textEdit->setFrameShadow(QFrame::Plain);
    m_textEdit->setFrameShape(QFrame::NoFrame);

    QFile file(m_notesFileName);
    if (file.open(QFile::ReadOnly))
    {
        m_textEdit->setPlainText(file.readAll());
        m_textEdit->moveCursor(QTextCursor::End);
        m_textEdit->document()->setModified(false);
    }

    connect(m_textEdit, &QPlainTextEdit::textChanged, [this] {
        m_saveTimer->start(10000);
    });

    /**/

    QPalette palette;
    palette.setBrush(QPalette::Window, QColor(0xF7DC9D));
    palette.setBrush(QPalette::Base, QColor(0xF7EC9D));

    setPalette(palette);

    addAction(saveAct);
    addAction(m_visibilityAct);
    addAction(stayOnBottomAct);
    addAction(closeAct);

    QGridLayout *gridLayout = new QGridLayout(this);
    gridLayout->addWidget(m_textEdit, 0, 0, 1, 2);
    gridLayout->addItem(new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Minimum), 1, 0, 1, 1);
    gridLayout->addWidget(new QSizeGrip(this), 1, 1, 1, 1);
    gridLayout->setMargin(0);

    /**/

    setContextMenuPolicy(Qt::CustomContextMenu);
    connect(this, &Notes::customContextMenuRequested, [this](const QPoint &p) {
        m_menu->popup(mapToGlobal(p));
    });

    Qt::WindowFlags flags = getNotesWindowFlags();
    if (m_settings.value("StayOnBottom", false).toBool())
    {
        flags |= Qt::WindowStaysOnBottomHint;
        stayOnBottomAct->setChecked(true);
    }
    setWindowFlags(flags);

    if (!restoreGeometry(m_settings.value("Geometry").toByteArray()))
        resize(300, 400);

    if (m_settings.value("Visible", true).toBool())
        toggleVisibility();
    else
        m_visible = false;
}
Example #14
0
void LightscreenWindow::createTrayIcon()
{
    mTrayIcon = new QSystemTrayIcon(QIcon(":/icons/lightscreen.small"), this);
    updateStatus();

    connect(mTrayIcon, &QSystemTrayIcon::messageClicked, this, &LightscreenWindow::messageClicked);
    connect(mTrayIcon, &QSystemTrayIcon::activated     , this, [&](QSystemTrayIcon::ActivationReason reason) {
        if (reason != QSystemTrayIcon::DoubleClick) return;
        toggleVisibility();
    });

    auto hideAction = new QAction(QIcon(":/icons/lightscreen.small"), tr("Show&/Hide"), mTrayIcon);
    connect(hideAction, &QAction::triggered, this, &LightscreenWindow::toggleVisibility);

    auto screenAction = new QAction(os::icon("screen"), tr("&Screen"), mTrayIcon);
    screenAction->setData(QVariant(0));

    auto windowAction = new QAction(os::icon("window"), tr("Active &Window"), this);
    windowAction->setData(QVariant(1));

    auto windowPickerAction = new QAction(os::icon("pickWindow"), tr("&Pick Window"), this);
    windowPickerAction->setData(QVariant(3));

    auto areaAction = new QAction(os::icon("area"), tr("&Area"), mTrayIcon);
    areaAction->setData(QVariant(2));

    auto screenshotGroup = new QActionGroup(mTrayIcon);
    screenshotGroup->addAction(screenAction);
    screenshotGroup->addAction(areaAction);
    screenshotGroup->addAction(windowAction);
    screenshotGroup->addAction(windowPickerAction);

    connect(screenshotGroup, &QActionGroup::triggered, this, &LightscreenWindow::screenshotActionTriggered);

    // Duplicated for the screenshot button :(
    auto uploadAction = new QAction(os::icon("imgur"), tr("&Upload last"), mTrayIcon);
    uploadAction->setToolTip(tr("Upload the last screenshot you took to imgur.com"));
    connect(uploadAction, &QAction::triggered, this, &LightscreenWindow::uploadLast);

    auto cancelAction = new QAction(os::icon("no"), tr("&Cancel upload"), mTrayIcon);
    cancelAction->setToolTip(tr("Cancel the currently uploading screenshots"));
    cancelAction->setEnabled(false);
    connect(this, &LightscreenWindow::uploading, cancelAction, &QAction::setEnabled);
    connect(cancelAction, &QAction::triggered, this, &LightscreenWindow::uploadCancel);

    auto historyAction = new QAction(os::icon("view-history"), tr("View History"), mTrayIcon);
    connect(historyAction, &QAction::triggered, this, &LightscreenWindow::showHistoryDialog);
    //

    auto optionsAction = new QAction(os::icon("configure"), tr("View &Options"), mTrayIcon);
    connect(optionsAction, &QAction::triggered, this, &LightscreenWindow::showOptions);

    auto goAction = new QAction(os::icon("folder"), tr("&Go to Folder"), mTrayIcon);
    connect(goAction, &QAction::triggered, this, &LightscreenWindow::goToFolder);

    auto quitAction = new QAction(tr("&Quit"), mTrayIcon);
    connect(quitAction, &QAction::triggered, this, &LightscreenWindow::quit);

    auto screenshotMenu = new QMenu(tr("Screenshot"));
    screenshotMenu->addAction(screenAction);
    screenshotMenu->addAction(areaAction);
    screenshotMenu->addAction(windowAction);
    screenshotMenu->addAction(windowPickerAction);

    // Duplicated for the screenshot button :(
    auto imgurMenu = new QMenu(tr("Upload"));
    imgurMenu->addAction(uploadAction);
    imgurMenu->addAction(cancelAction);
    imgurMenu->addAction(historyAction);
    imgurMenu->addSeparator();

    auto trayIconMenu = new QMenu;
    trayIconMenu->addAction(hideAction);
    trayIconMenu->addSeparator();
    trayIconMenu->addMenu(imgurMenu);
    trayIconMenu->addSeparator();
    trayIconMenu->addMenu(screenshotMenu);
    trayIconMenu->addAction(optionsAction);
    trayIconMenu->addAction(goAction);
    trayIconMenu->addSeparator();
    trayIconMenu->addAction(quitAction);

    mTrayIcon->setContextMenu(trayIconMenu);
}