RWebBrowser::RWebBrowser(ICore *api, QWidget *parent)
    : QWidget(parent),
      m_core(api),
      m_webView(new QWebView),
      m_locationEdit(new QLineEdit),
      m_buttonLayout(new QVBoxLayout),
      m_progress(0)
{

    //make sure we use application wide NetworkAccessManager:
    m_webView->page()->setNetworkAccessManager(m_core->networkAccessManager());

    //TODO: make this configurable via settings
    m_webView->settings()->setAttribute(QWebSettings::PluginsEnabled, true);

    m_locationEdit->setSizePolicy(QSizePolicy::Expanding, m_locationEdit->sizePolicy().verticalPolicy());

    QToolBar *toolBar = new QToolBar;

    toolBar->addAction(m_webView->pageAction(QWebPage::Back));
    toolBar->addAction(m_webView->pageAction(QWebPage::Forward));
    toolBar->addAction(m_webView->pageAction(QWebPage::Reload));
    toolBar->addAction(m_webView->pageAction(QWebPage::Stop));
    toolBar->addWidget(m_locationEdit);

    QObject::connect(m_webView, SIGNAL(loadFinished(bool)), SLOT(adjustLocation()));
    QObject::connect(m_webView, SIGNAL(titleChanged(QString)), SLOT(adjustTitle()));
    QObject::connect(m_webView, SIGNAL(loadProgress(int)), SLOT(setProgress(int)));
    QObject::connect(m_webView, SIGNAL(loadFinished(bool)), SLOT(finishLoading(bool)));
    QObject::connect(m_locationEdit, SIGNAL(returnPressed()), SLOT(changeLocation()));



    //TODO: load webpage given in user settings
    m_webView->load(QUrl("http://www.radiofrei.de/"));




    ///test zoom

    QSpinBox *sbox = new QSpinBox;
    sbox->setValue(100);
    sbox->setRange(30,200);
    sbox->setSingleStep(1);
    QObject::connect(sbox, SIGNAL(valueChanged(int)), SLOT(setZoom(int)));
    toolBar->addWidget(sbox);


    ///


    //create webView layout:
    QVBoxLayout *webLayout = new QVBoxLayout;
    webLayout->setSpacing(3);
    webLayout->setContentsMargins(0,0,0,0);
    webLayout->addWidget(toolBar);
    webLayout->addWidget(m_webView);

    //create main layout:
    QHBoxLayout *layout = new QHBoxLayout;
    layout->setSpacing(3);
    layout->setContentsMargins(0,0,0,0);
    layout->addLayout(webLayout);
    layout->addLayout(m_buttonLayout);

    setLayout(layout);




}
Ejemplo n.º 2
0
TransactionView::TransactionView(QWidget *parent) :
    QWidget(parent), model(0), transactionProxyModel(0),
    transactionView(0)
{
    // Build filter row
    setContentsMargins(0,0,0,0);

    QHBoxLayout *hlayout = new QHBoxLayout();
    hlayout->setContentsMargins(0,0,0,0);
#ifdef Q_WS_MAC
    hlayout->setSpacing(5);
    hlayout->addSpacing(26);
#else
    hlayout->setSpacing(0);
    hlayout->addSpacing(23);
#endif

    dateWidget = new QComboBox(this);
#ifdef Q_WS_MAC
    dateWidget->setFixedWidth(121);
#else
    dateWidget->setFixedWidth(120);
#endif
    dateWidget->addItem(tr("All"), All);
    dateWidget->addItem(tr("Today"), Today);
    dateWidget->addItem(tr("This week"), ThisWeek);
    dateWidget->addItem(tr("This month"), ThisMonth);
    dateWidget->addItem(tr("Last month"), LastMonth);
    dateWidget->addItem(tr("This year"), ThisYear);
    dateWidget->addItem(tr("Range..."), Range);
    hlayout->addWidget(dateWidget);

    typeWidget = new QComboBox(this);
#ifdef Q_WS_MAC
    typeWidget->setFixedWidth(121);
#else
    typeWidget->setFixedWidth(120);
#endif

    typeWidget->addItem(tr("All"), TransactionFilterProxy::ALL_TYPES);
    typeWidget->addItem(tr("Received with"), TransactionFilterProxy::TYPE(TransactionRecord::RecvWithAddress) |
                                        TransactionFilterProxy::TYPE(TransactionRecord::RecvFromOther));
    typeWidget->addItem(tr("Sent to"), TransactionFilterProxy::TYPE(TransactionRecord::SendToAddress) |
                                  TransactionFilterProxy::TYPE(TransactionRecord::SendToOther));
    typeWidget->addItem(tr("To yourself"), TransactionFilterProxy::TYPE(TransactionRecord::SendToSelf));
    typeWidget->addItem(tr("Mined"), TransactionFilterProxy::TYPE(TransactionRecord::Generated));
    typeWidget->addItem(tr("Other"), TransactionFilterProxy::TYPE(TransactionRecord::Other));

    hlayout->addWidget(typeWidget);

    addressWidget = new QLineEdit(this);
#if QT_VERSION >= 0x040700
    /* Do not move this to the XML file, Qt before 4.7 will choke on it */
    addressWidget->setPlaceholderText(tr("Enter address or label to search"));
#endif
    hlayout->addWidget(addressWidget);

    amountWidget = new QLineEdit(this);
#if QT_VERSION >= 0x040700
    /* Do not move this to the XML file, Qt before 4.7 will choke on it */
    amountWidget->setPlaceholderText(tr("Min amount"));
#endif
#ifdef Q_WS_MAC
    amountWidget->setFixedWidth(97);
#else
    amountWidget->setFixedWidth(100);
#endif
    amountWidget->setValidator(new QDoubleValidator(0, 1e20, 8, this));
    hlayout->addWidget(amountWidget);

    QVBoxLayout *vlayout = new QVBoxLayout(this);
    vlayout->setContentsMargins(0,0,0,0);
    vlayout->setSpacing(0);

    QTableView *view = new QTableView(this);
    vlayout->addLayout(hlayout);
    vlayout->addWidget(createDateRangeWidget());
    vlayout->addWidget(view);
    vlayout->setSpacing(0);
    int width = view->verticalScrollBar()->sizeHint().width();
    // Cover scroll bar width with spacing
#ifdef Q_WS_MAC
    hlayout->addSpacing(width+2);
#else
    hlayout->addSpacing(width);
#endif
    // Always show scroll bar
    view->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
    view->setTabKeyNavigation(false);
    view->setContextMenuPolicy(Qt::CustomContextMenu);

    transactionView = view;

    // Actions
    QAction *copyAddressAction = new QAction(tr("Copy address"), this);
    QAction *copyLabelAction = new QAction(tr("Copy label"), this);
    QAction *copyAmountAction = new QAction(tr("Copy amount"), this);
    QAction *editLabelAction = new QAction(tr("Edit label"), this);
    QAction *showDetailsAction = new QAction(tr("Show transaction details"), this);

    contextMenu = new QMenu();
    contextMenu->addAction(copyAddressAction);
    contextMenu->addAction(copyLabelAction);
    contextMenu->addAction(copyAmountAction);
    contextMenu->addAction(editLabelAction);
    contextMenu->addAction(showDetailsAction);

    // Connect actions
    connect(dateWidget, SIGNAL(activated(int)), this, SLOT(chooseDate(int)));
    connect(typeWidget, SIGNAL(activated(int)), this, SLOT(chooseType(int)));
    connect(addressWidget, SIGNAL(textChanged(QString)), this, SLOT(changedPrefix(QString)));
    connect(amountWidget, SIGNAL(textChanged(QString)), this, SLOT(changedAmount(QString)));

    connect(view, SIGNAL(doubleClicked(QModelIndex)), this, SIGNAL(doubleClicked(QModelIndex)));
    connect(view, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(contextualMenu(QPoint)));

    connect(copyAddressAction, SIGNAL(triggered()), this, SLOT(copyAddress()));
    connect(copyLabelAction, SIGNAL(triggered()), this, SLOT(copyLabel()));
    connect(copyAmountAction, SIGNAL(triggered()), this, SLOT(copyAmount()));
    connect(editLabelAction, SIGNAL(triggered()), this, SLOT(editLabel()));
    connect(showDetailsAction, SIGNAL(triggered()), this, SLOT(showDetails()));
}
Ejemplo n.º 3
0
BitcoinGUI::BitcoinGUI(QWidget *parent):
    QMainWindow(parent),
    clientModel(0),
    walletModel(0),
    encryptWalletAction(0),
    changePassphraseAction(0),
    aboutQtAction(0),
    trayIcon(0),
    notificator(0),
    rpcConsole(0)
{
    resize(850, 550);
    setWindowTitle(tr("BitpopCoin") + " - " + tr("Wallet"));
#ifndef Q_WS_MAC
    qApp->setWindowIcon(QIcon(":icons/bitcoin"));
    setWindowIcon(QIcon(":icons/bitcoin"));
#else
    setUnifiedTitleAndToolBarOnMac(true);
    QApplication::setAttribute(Qt::AA_DontShowIconsInMenus);
#endif
    // Accept D&D of URIs
    setAcceptDrops(true);

    // Create actions for the toolbar, menu bar and tray/dock icon
    createActions();

    // Create application menu bar
    createMenuBar();

    // Create the toolbars
    createToolBars();

    // Create the tray icon (or setup the dock icon)
    createTrayIcon();

    // Create tabs
    overviewPage = new OverviewPage();

    miningPage = new MiningPage(this);

    transactionsPage = new QWidget(this);
    QVBoxLayout *vbox = new QVBoxLayout();
    transactionView = new TransactionView(this);
    vbox->addWidget(transactionView);
    transactionsPage->setLayout(vbox);

    addressBookPage = new AddressBookPage(AddressBookPage::ForEditing, AddressBookPage::SendingTab);

    receiveCoinsPage = new AddressBookPage(AddressBookPage::ForEditing, AddressBookPage::ReceivingTab);

    sendCoinsPage = new SendCoinsDialog(this);

    signVerifyMessageDialog = new SignVerifyMessageDialog(this);

    centralWidget = new QStackedWidget(this);
    centralWidget->addWidget(overviewPage);
    centralWidget->addWidget(miningPage);
    centralWidget->addWidget(transactionsPage);
    centralWidget->addWidget(addressBookPage);
    centralWidget->addWidget(receiveCoinsPage);
    centralWidget->addWidget(sendCoinsPage);
#ifdef FIRST_CLASS_MESSAGING
    centralWidget->addWidget(signVerifyMessageDialog);
#endif
    setCentralWidget(centralWidget);

    // Create status bar
    statusBar();

    // Status bar notification icons
    QFrame *frameBlocks = new QFrame();
    frameBlocks->setContentsMargins(0,0,0,0);
    frameBlocks->setMinimumWidth(73);
    frameBlocks->setMaximumWidth(73);
    QHBoxLayout *frameBlocksLayout = new QHBoxLayout(frameBlocks);
    frameBlocksLayout->setContentsMargins(3,0,3,0);
    frameBlocksLayout->setSpacing(3);
    labelEncryptionIcon = new QLabel();
    labelMiningIcon = new QLabel();
    labelConnectionsIcon = new QLabel();
    labelBlocksIcon = new QLabel();
    frameBlocksLayout->addStretch();
    frameBlocksLayout->addWidget(labelEncryptionIcon);
    frameBlocksLayout->addStretch();
    frameBlocksLayout->addWidget(labelMiningIcon);
    frameBlocksLayout->addStretch();
    frameBlocksLayout->addWidget(labelConnectionsIcon);
    frameBlocksLayout->addStretch();
    frameBlocksLayout->addWidget(labelBlocksIcon);
    frameBlocksLayout->addStretch();

    // Progress bar and label for blocks download
    progressBarLabel = new QLabel();
    progressBarLabel->setVisible(false);
    progressBar = new QProgressBar();
    progressBar->setAlignment(Qt::AlignCenter);
    progressBar->setVisible(false);

    statusBar()->addWidget(progressBarLabel);
    statusBar()->addWidget(progressBar);
    statusBar()->addPermanentWidget(frameBlocks);

    syncIconMovie = new QMovie(":/movies/update_spinner", "mng", this);

    // Clicking on a transaction on the overview page simply sends you to transaction history page
    connect(overviewPage, SIGNAL(transactionClicked(QModelIndex)), this, SLOT(gotoHistoryPage()));
    connect(overviewPage, SIGNAL(transactionClicked(QModelIndex)), transactionView, SLOT(focusTransaction(QModelIndex)));

    // Doubleclicking on a transaction on the transaction history page shows details
    connect(transactionView, SIGNAL(doubleClicked(QModelIndex)), transactionView, SLOT(showDetails()));

    rpcConsole = new RPCConsole(this);
    connect(openRPCConsoleAction, SIGNAL(triggered()), rpcConsole, SLOT(show()));

    // Clicking on "Verify Message" in the address book sends you to the verify message tab
    connect(addressBookPage, SIGNAL(verifyMessage(QString)), this, SLOT(gotoVerifyMessageTab(QString)));
    // Clicking on "Sign Message" in the receive coins page sends you to the sign message tab
    connect(receiveCoinsPage, SIGNAL(signMessage(QString)), this, SLOT(gotoSignMessageTab(QString)));

    gotoOverviewPage();
}
Ejemplo n.º 4
0
void UIVMCloseDialog::prepare()
{
    /* Prepare 'main' layout: */
    QVBoxLayout *pMainLayout = new QVBoxLayout(this);
    {
        /* Prepare 'top' layout: */
        QHBoxLayout *pTopLayout = new QHBoxLayout;
        {
            /* Prepare 'top-left' layout: */
            QVBoxLayout *pTopLeftLayout = new QVBoxLayout;
            {
                /* Prepare 'icon': */
                m_pIcon = new QLabel(this);
                {
                    /* Configure icon: */
                    m_pIcon->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
                    m_pIcon->setPixmap(QPixmap(":/os_unknown.png"));
                }
                /* Configure layout: */
                pTopLeftLayout->setSpacing(0);
                pTopLeftLayout->setContentsMargins(0, 0, 0, 0);
                pTopLeftLayout->addWidget(m_pIcon);
                pTopLeftLayout->addStretch();
            }
            /* Prepare 'top-right' layout: */
            QVBoxLayout *pTopRightLayout = new QVBoxLayout;
            {
                /* Prepare 'text' label: */
                m_pLabel = new QLabel(this);
                /* Prepare 'choice' layout: */
                QGridLayout *pChoiceLayout = new QGridLayout;
                {
                    /* Prepare 'detach' icon: */
                    m_pDetachIcon = new QLabel(this);
                    {
                        /* Configure icon: */
                        m_pDetachIcon->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
                        m_pDetachIcon->setPixmap(QPixmap(":/vm_create_shortcut_16px.png"));
                    }
                    /* Prepare 'detach' radio-button: */
                    m_pDetachRadio = new QRadioButton(this);
                    {
                        /* Configure button: */
                        m_pDetachRadio->installEventFilter(this);
                        connect(m_pDetachRadio, SIGNAL(toggled(bool)), this, SLOT(sltUpdateWidgetAvailability()));
                    }
                    /* Prepare 'save' icon: */
                    m_pSaveIcon = new QLabel(this);
                    {
                        /* Configure icon: */
                        m_pSaveIcon->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
                        m_pSaveIcon->setPixmap(QPixmap(":/vm_save_state_16px.png"));
                    }
                    /* Prepare 'save' radio-button: */
                    m_pSaveRadio = new QRadioButton(this);
                    {
                        /* Configure button: */
                        m_pSaveRadio->installEventFilter(this);
                        connect(m_pSaveRadio, SIGNAL(toggled(bool)), this, SLOT(sltUpdateWidgetAvailability()));
                    }
                    /* Prepare 'shutdown' icon: */
                    m_pShutdownIcon = new QLabel(this);
                    {
                        /* Configure icon: */
                        m_pShutdownIcon->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
                        m_pShutdownIcon->setPixmap(QPixmap(":/vm_shutdown_16px.png"));
                    }
                    /* Prepare 'shutdown' radio-button: */
                    m_pShutdownRadio = new QRadioButton(this);
                    {
                        /* Configure button: */
                        m_pShutdownRadio->installEventFilter(this);
                        connect(m_pShutdownRadio, SIGNAL(toggled(bool)), this, SLOT(sltUpdateWidgetAvailability()));
                    }
                    /* Prepare 'power-off' icon: */
                    m_pPowerOffIcon = new QLabel(this);
                    {
                        /* Configure icon: */
                        m_pPowerOffIcon->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
                        m_pPowerOffIcon->setPixmap(QPixmap(":/vm_poweroff_16px.png"));
                    }
                    /* Prepare 'shutdown' radio-button: */
                    m_pPowerOffRadio = new QRadioButton(this);
                    {
                        /* Configure button: */
                        m_pPowerOffRadio->installEventFilter(this);
                        connect(m_pPowerOffRadio, SIGNAL(toggled(bool)), this, SLOT(sltUpdateWidgetAvailability()));
                    }
                    /* Prepare 'discard' check-box: */
                    m_pDiscardCheckBox = new QCheckBox(this);
                    /* Configure layout: */
#ifdef Q_WS_MAC
                    pChoiceLayout->setSpacing(15);
#else /* Q_WS_MAC */
                    pChoiceLayout->setSpacing(6);
#endif /* !Q_WS_MAC */
                    pChoiceLayout->setContentsMargins(0, 0, 0, 0);
                    pChoiceLayout->addWidget(m_pDetachIcon, 0, 0);
                    pChoiceLayout->addWidget(m_pDetachRadio, 0, 1);
                    pChoiceLayout->addWidget(m_pSaveIcon, 1, 0);
                    pChoiceLayout->addWidget(m_pSaveRadio, 1, 1);
                    pChoiceLayout->addWidget(m_pShutdownIcon, 2, 0);
                    pChoiceLayout->addWidget(m_pShutdownRadio, 2, 1);
                    pChoiceLayout->addWidget(m_pPowerOffIcon, 3, 0);
                    pChoiceLayout->addWidget(m_pPowerOffRadio, 3, 1);
                    pChoiceLayout->addWidget(m_pDiscardCheckBox, 4, 1);
                }
                /* Configure layout: */
#ifdef Q_WS_MAC
                pTopRightLayout->setSpacing(15);
#else /* Q_WS_MAC */
                pTopRightLayout->setSpacing(6);
#endif /* !Q_WS_MAC */
                pTopRightLayout->setContentsMargins(0, 0, 0, 0);
                pTopRightLayout->addWidget(m_pLabel);
                pTopRightLayout->addItem(pChoiceLayout);
            }
            /* Configure layout: */
            pTopLayout->setSpacing(20);
            pTopLayout->setContentsMargins(0, 0, 0, 0);
            pTopLayout->addItem(pTopLeftLayout);
            pTopLayout->addItem(pTopRightLayout);
        }
        /* Prepare button-box: */
        QIDialogButtonBox *pButtonBox = new QIDialogButtonBox(this);
        {
            /* Configure button-box: */
            pButtonBox->setStandardButtons(QDialogButtonBox::Cancel | QDialogButtonBox::Help | QDialogButtonBox::NoButton | QDialogButtonBox::Ok);
            connect(pButtonBox, SIGNAL(accepted()), this, SLOT(accept()));
            connect(pButtonBox, SIGNAL(rejected()), this, SLOT(reject()));
            connect(pButtonBox, SIGNAL(helpRequested()), &msgCenter(), SLOT(sltShowHelpHelpDialog()));
        }
        /* Configure layout: */
        pMainLayout->setSpacing(20);
#ifdef Q_WS_MAC
        pMainLayout->setContentsMargins(40, 20, 40, 20);
#endif /* Q_WS_MAC */
        pMainLayout->addItem(pTopLayout);
        pMainLayout->addWidget(pButtonBox);
    }
    /* Prepare size-grip token: */
    setSizeGripEnabled(false);
}
Ejemplo n.º 5
0
BitcoinGUI::BitcoinGUI(QWidget *parent):
    QMainWindow(parent),
    clientModel(0),
    walletModel(0),
    encryptWalletAction(0),
    changePassphraseAction(0),
    unlockWalletAction(0),
    lockWalletAction(0),
    aboutQtAction(0),
    trayIcon(0),
    notificator(0),
    rpcConsole(0)
{
    resize(850, 550);
    setWindowTitle(tr("fairbyte") + " - " + tr("Wallet"));
#ifndef Q_OS_MAC
    qApp->setWindowIcon(QIcon(":icons/bitcoin"));
    setWindowIcon(QIcon(":icons/bitcoin"));
#else
    setUnifiedTitleAndToolBarOnMac(true);
    QApplication::setAttribute(Qt::AA_DontShowIconsInMenus);
#endif
    // Accept D&D of URIs
    setAcceptDrops(true);

    // Create actions for the toolbar, menu bar and tray/dock icon
    createActions();

    // Create application menu bar
    createMenuBar();

    // Create the toolbars
    createToolBars();

    // Create the tray icon (or setup the dock icon)
    createTrayIcon();

    // Create tabs
    overviewPage = new OverviewPage();

    transactionsPage = new QWidget(this);
    QVBoxLayout *vbox = new QVBoxLayout();
    transactionView = new TransactionView(this);
    vbox->addWidget(transactionView);
    transactionsPage->setLayout(vbox);

    addressBookPage = new AddressBookPage(AddressBookPage::ForEditing, AddressBookPage::SendingTab);

    receiveCoinsPage = new AddressBookPage(AddressBookPage::ForEditing, AddressBookPage::ReceivingTab);

    sendCoinsPage = new SendCoinsDialog(this);

    signVerifyMessageDialog = new SignVerifyMessageDialog(this);

    centralWidget = new QStackedWidget(this);
    centralWidget->addWidget(overviewPage);
    centralWidget->addWidget(transactionsPage);
    centralWidget->addWidget(addressBookPage);
    centralWidget->addWidget(receiveCoinsPage);
    centralWidget->addWidget(sendCoinsPage);
    setCentralWidget(centralWidget);

    // Create status bar
    statusBar();

    // Status bar notification icons
    QFrame *frameBlocks = new QFrame();
    frameBlocks->setContentsMargins(0,0,0,0);
    frameBlocks->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Preferred);
    QHBoxLayout *frameBlocksLayout = new QHBoxLayout(frameBlocks);
    frameBlocksLayout->setContentsMargins(3,0,3,0);
    frameBlocksLayout->setSpacing(3);
    labelEncryptionIcon = new QLabel();
    labelStakingIcon = new QLabel();
    labelConnectionsIcon = new QLabel();
    labelBlocksIcon = new QLabel();
    frameBlocksLayout->addStretch();
    frameBlocksLayout->addWidget(labelEncryptionIcon);
    frameBlocksLayout->addStretch();
    frameBlocksLayout->addWidget(labelStakingIcon);
    frameBlocksLayout->addStretch();
    frameBlocksLayout->addWidget(labelConnectionsIcon);
    frameBlocksLayout->addStretch();
    frameBlocksLayout->addWidget(labelBlocksIcon);
    frameBlocksLayout->addStretch();

    if (GetBoolArg("-staking", true))
    {
        QTimer *timerStakingIcon = new QTimer(labelStakingIcon);
        connect(timerStakingIcon, SIGNAL(timeout()), this, SLOT(updateStakingIcon()));
        timerStakingIcon->start(30 * 1000);
        updateStakingIcon();
    }

    // Progress bar and label for blocks download
    progressBarLabel = new QLabel();
    progressBarLabel->setVisible(false);
    progressBar = new QProgressBar();
    progressBar->setAlignment(Qt::AlignCenter);
    progressBar->setVisible(false);

    // Override style sheet for progress bar for styles that have a segmented progress bar,
    // as they make the text unreadable (workaround for issue #1071)
    // See https://qt-project.org/doc/qt-4.8/gallery.html
    QString curStyle = qApp->style()->metaObject()->className();
    if(curStyle == "QWindowsStyle" || curStyle == "QWindowsXPStyle")
    {
        progressBar->setStyleSheet("QProgressBar { background-color: #e8e8e8; border: 1px solid grey; border-radius: 7px; padding: 1px; text-align: center; } QProgressBar::chunk { background: QLinearGradient(x1: 0, y1: 0, x2: 1, y2: 0, stop: 0 #FF8000, stop: 1 orange); border-radius: 7px; margin: 0px; }");
    }

    statusBar()->addWidget(progressBarLabel);
    statusBar()->addWidget(progressBar);
    statusBar()->addPermanentWidget(frameBlocks);

    syncIconMovie = new QMovie(":/movies/update_spinner", "mng", this);

    // Clicking on a transaction on the overview page simply sends you to transaction history page
    connect(overviewPage, SIGNAL(transactionClicked(QModelIndex)), this, SLOT(gotoHistoryPage()));
    connect(overviewPage, SIGNAL(transactionClicked(QModelIndex)), transactionView, SLOT(focusTransaction(QModelIndex)));

    // Double-clicking on a transaction on the transaction history page shows details
    connect(transactionView, SIGNAL(doubleClicked(QModelIndex)), transactionView, SLOT(showDetails()));

    rpcConsole = new RPCConsole(this);
    connect(openRPCConsoleAction, SIGNAL(triggered()), rpcConsole, SLOT(show()));

    // Clicking on "Verify Message" in the address book sends you to the verify message tab
    connect(addressBookPage, SIGNAL(verifyMessage(QString)), this, SLOT(gotoVerifyMessageTab(QString)));
    // Clicking on "Sign Message" in the receive coins page sends you to the sign message tab
    connect(receiveCoinsPage, SIGNAL(signMessage(QString)), this, SLOT(gotoSignMessageTab(QString)));

    gotoOverviewPage();
}
Ejemplo n.º 6
0
FindBar::FindBar(MainWindow *window)
        : QWidget(window)
        , m_mainWindow(window)
        , m_lineEdit(new KLineEdit(this))
        , m_hideTimer(new QTimer(this))
        , m_matchCase(new QCheckBox(i18n("&Match case"), this))
        , m_highlightAll(new QCheckBox(i18n("&Highlight all"), this))
{
    QHBoxLayout *layout = new QHBoxLayout;

    // cosmetic
    layout->setContentsMargins(2, 0, 2, 0);

    // hide button
    QToolButton *hideButton = new QToolButton(this);
    hideButton->setAutoRaise(true);
    hideButton->setIcon(KIcon("dialog-close"));
    connect(hideButton, SIGNAL(clicked()), this, SLOT(hide()));
    layout->addWidget(hideButton);
    layout->setAlignment(hideButton, Qt::AlignLeft | Qt::AlignTop);

    // hide timer
    connect(m_hideTimer, SIGNAL(timeout()), this, SLOT(hide()));
    m_hideTimer->setSingleShot(true);

    // label
    QLabel *label = new QLabel(i18n("Find:"));
    layout->addWidget(label);

    // lineEdit, focusProxy
    setFocusProxy(m_lineEdit);
    m_lineEdit->setMaximumWidth(250);
    connect(m_lineEdit, SIGNAL(textChanged(const QString &)), window, SLOT(find(const QString &)));
    layout->addWidget(m_lineEdit);

    // buttons
    KPushButton *findNext = new KPushButton(KIcon("go-down"), i18n("&Next"), this);
    KPushButton *findPrev = new KPushButton(KIcon("go-up"), i18n("&Previous"), this);
    connect(findNext, SIGNAL(clicked()), window, SLOT(findNext()));
    connect(findPrev, SIGNAL(clicked()), window, SLOT(findPrevious()));
    layout->addWidget(findNext);
    layout->addWidget(findPrev);

    // Case sensitivity. Deliberately set so this is off by default.
    m_matchCase->setCheckState(Qt::Unchecked);
    m_matchCase->setTristate(false);
    connect(m_matchCase, SIGNAL(toggled(bool)), window, SLOT(matchCaseUpdate()));
    layout->addWidget(m_matchCase);

    // Hightlight All. On by default
    m_highlightAll->setCheckState(Qt::Checked);
    m_highlightAll->setTristate(false);
    connect(m_highlightAll, SIGNAL(toggled(bool)), window, SLOT(updateHighlight()));
    layout->addWidget(m_highlightAll);

    // stretching widget on the left
    layout->addStretch();

    setLayout(layout);

    // we start off hidden
    hide();
}
Ejemplo n.º 7
0
KexiView::KexiView(QWidget *parent)
        : QWidget(parent)
        , KexiActionProxy(this)
        , d(new Private(this))
{
    QWidget *wi = this;
    while ((wi = wi->parentWidget()) && !wi->inherits("KexiWindow"))
        ;
    d->window = (wi && wi->inherits("KexiWindow")) ? static_cast<KexiWindow*>(wi) : 0;
    if (d->window) {
        //init view mode number for this view (obtained from window where this view is created)
        if (d->window->supportsViewMode(d->window->creatingViewsMode()))
            d->viewMode = d->window->creatingViewsMode();
    }
    setObjectName(
        QString("%1_for_%2_object")
        .arg(Kexi::nameForViewMode(d->viewMode).replace(' ', '_'))
        .arg(d->window ? d->window->partItem()->name() : QString("??")));

    installEventFilter(this);

    // QLayout *l = layout(); -- FIXME: Not used?
    d->mainLyr = new QVBoxLayout(this);
    d->mainLyr->setContentsMargins(0, KDialog::marginHint() / 3, 0, 0);

    if (parentWidget()->inherits("KexiWindow")) {
        d->topBarHWidget = new QWidget(this);
        d->topBarHWidget->setFont(KexiUtils::smallFont());
        d->mainLyr->addWidget(d->topBarHWidget);
        QHBoxLayout *topBarHLyr = new QHBoxLayout(d->topBarHWidget); //needed unless KexiFlowLayout properly handles contents margins
        topBarHLyr->setContentsMargins(0, 0, 0, 0);
        topBarHLyr->addSpacing(KDialog::marginHint() / 2);
        d->topBarLyr = new KexiFlowLayout(topBarHLyr, KDialog::marginHint() / 2, 2);

        const bool userMode = KexiMainWindowIface::global()->userMode();

        bool addSeparator = false;
        if (userMode
                || d->window->supportedViewModes() == Kexi::DataViewMode
                || d->window->supportedViewModes() == Kexi::DesignViewMode
                || d->window->supportedViewModes() == Kexi::TextViewMode)
        {
            // nothing to do: only single view mode supported
        }
        else {
            if (parentWidget()->inherits("KexiWindow")) {
                createViewModeToggleButtons();
            }
        }

        (void)d->mainMenu();

        if (d->viewMode == Kexi::DesignViewMode || d->viewMode == Kexi::TextViewMode) {
            if (addSeparator) {
                d->topBarLyr->addWidget(new KexiToolBarSeparator(d->topBarHWidget));
                addSeparator = false;
            }

            QAction *a = sharedAction("project_save");
            d->saveDesignButton = new KexiSmallToolButton(a, d->topBarHWidget);
            d->saveDesignButton->setText(i18n("Save"));
            d->saveDesignButton->setToolTip(i18n("Save current design"));
            d->saveDesignButton->setWhatsThis(i18n("Saves changes made to the current design."));
            d->topBarLyr->addWidget(d->saveDesignButton);

            a = sharedAction("project_saveas");
            d->mainMenu()->addAction(a);
        }
        else {
            d->saveDesignButton = 0;
        }
    } else {
        // no toolbar
        d->saveDesignButton = 0;
        d->topBarHWidget = 0;
        d->topBarLyr = 0;
    }
}
Ejemplo n.º 8
0
void MixerGUI::updateGUI(){
  //Load the list of available devices
  QStringList devList = Mixer::getDevices();
  //devList.sort();
  //Clear the UI
  ui->combo_default->disconnect();
  ui->combo_default->clear();
  ui->combo_record->disconnect();
  ui->combo_record->clear();
  ui->combo_outdevice->disconnect();
  ui->combo_outdevice->clear();
  delete ui->scrollArea->widget(); //delete the widget and all children
  ui->scrollArea->setWidget( new QWidget() ); //create a new widget in the scroll area
  ui->scrollArea->widget()->setContentsMargins(0,0,0,0);
  QHBoxLayout *layout = new QHBoxLayout;
  //Now Fill the UI with the devices
  QString cdefault ="none";
  QString rdefault = Mixer::getRecDevice();
  if(settings!=0){
    cdefault = settings->value("tray-device", "vol").toString();
  }
  for(int i=0; i<devList.length(); i++){
    //Get the individual pieces
    QString dev = devList[i].section(":",0,0);
    int Lval = devList[i].section(":",1,1).toInt();
    int Rval = devList[i].section(":",2,2).toInt();
    //Now create the device widget
    DeviceWidget *device = new DeviceWidget(this);
      device->setupDevice(dev, Lval, Rval);
      layout->addWidget(device);
      connect(device, SIGNAL(deviceChanged(QString)), this, SLOT(itemChanged(QString)) );
    //Now add the device to the default/record lists
    ui->combo_default->addItem(dev);
    ui->combo_record->addItem(dev);
    if(dev == cdefault){
      ui->combo_default->setCurrentIndex(i);
    }
    if(dev == rdefault){
      ui->combo_record->setCurrentIndex(i);
    }
  }
  layout->addStretch(); //add spacer to the end
  layout->setContentsMargins(2,2,2,2);
  layout->setSpacing(4);
  ui->scrollArea->widget()->setLayout(layout);
  ui->scrollArea->setMinimumHeight(ui->scrollArea->widget()->minimumSizeHint().height()+ui->scrollArea->horizontalScrollBar()->height());
  //Now rebuild the output device list
  QStringList outdevs = pcbsd::Utils::runShellCommand("pc-sysconfig list-audiodev").join("").split(", ");
  for(int i=0; i<outdevs.length(); i++){
    if(outdevs[i].startsWith("pcm")){
      ui->combo_outdevice->addItem(outdevs[i].section(" default",0,0), outdevs[i].section(":",0,0) );
      if(outdevs[i].contains(" default")){ ui->combo_outdevice->setCurrentIndex( ui->combo_outdevice->count()-1); }
    }
  }
  ui->combo_outdevice->setEnabled(ui->combo_outdevice->count() > 0);
  //re-connect combobox signal
  connect(ui->combo_default, SIGNAL(currentIndexChanged(QString)), this, SLOT(changeDefaultTrayDevice(QString)) );
  connect(ui->combo_record, SIGNAL(currentIndexChanged(QString)), this, SLOT(changeRecordingDevice(QString)) );
  connect(ui->combo_outdevice, SIGNAL(currentIndexChanged(QString)), this, SLOT(changeOutputDevice()) );
  //Hide the tray icon controls if necessary
  ui->combo_default->setVisible(settings!=0);
  ui->label_tray->setVisible(settings!=0);
  ui->actionClose_Mixer_and_Tray->setVisible(settings!=0);
}
Ejemplo n.º 9
0
void NpiWidget::initialize()
{
    setTitle("Non-Pharmaceutical Intervention");

    QVBoxLayout * layout = new QVBoxLayout();
    setLayout(layout);

    QWidget * nameWidget = new QWidget();
    QHBoxLayout * nameHBox = new QHBoxLayout();
    nameWidget->setLayout(nameHBox);

    QLabel * nameLabel = new QLabel("Name");
    nameLineEdit_ = new QLineEdit();

    nameHBox->addWidget(nameLabel);
    nameHBox->addWidget(nameLineEdit_);

    layout->addWidget(nameWidget);

    // add other widgets

    // add initially-hidden execution time label
    layout->addWidget(&executionTimeLabel_);
    executionTimeLabel_.hide();

    // add duration spinbox
    {
        durationSpinBox_ = new QSpinBox();
        durationSpinBox_->setMinimum(1);
        durationSpinBox_->setMaximum(365);
        durationSpinBox_->setSuffix(" days");

        // add in horizontal layout with label
        QWidget * widget = new QWidget();
        QHBoxLayout * hBox = new QHBoxLayout();
        widget->setLayout(hBox);

        hBox->addWidget(new QLabel("Duration"));
        hBox->addWidget(durationSpinBox_);

        // reduce layout spacing
        hBox->setContentsMargins(QMargins(0,0,0,0));

        // add to main layout
        layout->addWidget(widget);
    }

    // add stratification effectiveness widgets (age group only)
    {
        QGroupBox * groupBox = new QGroupBox();
        groupBox->setTitle("Age-specific effectiveness");

        QVBoxLayout * vBox = new QVBoxLayout();
        groupBox->setLayout(vBox);

        std::vector<std::vector<std::string> > stratifications = EpidemicDataSet::getStratifications();

        // add stratification checkboxes for first stratification type
        for(unsigned int j=0; j<stratifications[0].size(); j++)
        {
            QDoubleSpinBox * spinBox = new QDoubleSpinBox();
            spinBox->setMinimum(0.);
            spinBox->setMaximum(1.0);
            spinBox->setSingleStep(0.01);

            ageEffectivenessSpinBoxes_.push_back(spinBox);

            // add in horizontal layout with label
            QWidget * widget = new QWidget();
            QHBoxLayout * hBox = new QHBoxLayout();
            widget->setLayout(hBox);

            hBox->addWidget(new QLabel(stratifications[0][j].c_str()));
            hBox->addWidget(spinBox);

            // reduce layout spacing
            hBox->setContentsMargins(QMargins(0,0,0,0));

            // add to vertical layout of group box
            vBox->addWidget(widget);
        }

        layout->addWidget(groupBox);
    }

    // add location type choices widget
    {
        locationTypeComboBox_.addItem("Statewide", "statewide");
        locationTypeComboBox_.addItem("By region", "region");
        locationTypeComboBox_.addItem("By county", "county");

        // add in horizontal layout with label
        QWidget * widget = new QWidget();
        QHBoxLayout * hBox = new QHBoxLayout();
        widget->setLayout(hBox);

        hBox->addWidget(new QLabel("Location"));
        hBox->addWidget(&locationTypeComboBox_);

        // reduce layout spacing
        hBox->setContentsMargins(QMargins(0,0,0,0));

        layout->addWidget(widget);

        connect(&locationTypeComboBox_, SIGNAL(currentIndexChanged(int)), this, SLOT(setLocationType(int)));
    }

    // add group checkboxes widgets
    {
        groupGroupBox_ = new QGroupBox();
        groupGroupBox_->setTitle("Regions");

        QVBoxLayout * vBox = new QVBoxLayout();
        groupGroupBox_->setLayout(vBox);

        std::vector<std::string> groupNames = dataSet_->getGroupNames();

        // for each group name
        for(unsigned int i=0; i<groupNames.size(); i++)
        {
            QCheckBox * checkBox = new QCheckBox(groupNames[i].c_str());
            checkBox->setCheckState(Qt::Unchecked);

            vBox->addWidget(checkBox);

            groupCheckBoxes_.push_back(checkBox);
        }

        layout->addWidget(groupGroupBox_);

        // hide by default
        groupGroupBox_->hide();
    }

    // add node checkboxes widgets
    {
        nodeGroupBox_ = new QGroupBox();
        nodeGroupBox_->setTitle("Counties");

        QVBoxLayout * vBox = new QVBoxLayout();
        nodeGroupBox_->setLayout(vBox);

        std::vector<int> nodeIds = dataSet_->getNodeIds();

        // for each node
        for(unsigned int i=0; i<nodeIds.size(); i++)
        {
            QCheckBox * checkBox = new QCheckBox(dataSet_->getNodeName(nodeIds[i]).c_str());
            checkBox->setCheckState(Qt::Unchecked);

            vBox->addWidget(checkBox);

            nodeCheckBoxes_.push_back(checkBox);
        }

        layout->addWidget(nodeGroupBox_);

        // hide by default
        nodeGroupBox_->hide();
    }

    // cancel / save buttons
    cancelSaveButtonsWidget_ = new QWidget();

    QHBoxLayout * hBox = new QHBoxLayout();
    cancelSaveButtonsWidget_->setLayout(hBox);

    QPushButton * cancelButton = new QPushButton("&Cancel");
    hBox->addWidget(cancelButton);

    QPushButton * saveButton = new QPushButton("&Execute");
    hBox->addWidget(saveButton);

    // make connections
    connect(cancelButton, SIGNAL(clicked()), this, SLOT(cancel()));
    connect(saveButton, SIGNAL(clicked()), this, SLOT(save()));

    layout->addWidget(cancelSaveButtonsWidget_);
}
Ejemplo n.º 10
0
void memory_viewer_panel::ShowImage(QWidget* parent, u32 addr, int mode, u32 width, u32 height, bool flipv)
{
	QImage::Format format;
	unsigned char* originalBuffer  = (unsigned char*)vm::base(addr);
	unsigned char* convertedBuffer = (unsigned char*)malloc(width * height * 4);
	switch(mode)
	{
	case(0): // RGB
		for (u32 y = 0; y < height; y++) {
			for (u32 i = 0, j = 0; j < width * 4; i += 4, j += 3) {
				convertedBuffer[i + 0 + y * width * 4] = originalBuffer[j + 2 + y * width * 3];
				convertedBuffer[i + 1 + y * width * 4] = originalBuffer[j + 1 + y * width * 3];
				convertedBuffer[i + 2 + y * width * 4] = originalBuffer[j + 0 + y * width * 3];
				convertedBuffer[i + 3 + y * width * 4] = 255;
			}
		}
	break;
	
	case(1): // ARGB
		for (u32 y = 0; y < height; y++) {
			for (u32 i = 0, j = 0; j < width * 4; i += 4, j += 4) {
				convertedBuffer[i + 0 + y * width * 4] = originalBuffer[j + 3 + y * width * 4];
				convertedBuffer[i + 1 + y * width * 4] = originalBuffer[j + 2 + y * width * 4];
				convertedBuffer[i + 2 + y * width * 4] = originalBuffer[j + 1 + y * width * 4];
				convertedBuffer[i + 3 + y * width * 4] = originalBuffer[j + 0 + y * width * 4];
			}
		}
	break;
	
	case(2): // RGBA
		for (u32 y = 0; y < height; y++) {
			for (u32 i = 0, j = 0; j < width * 4; i += 4, j += 4) {
				convertedBuffer[i + 0 + y * width * 4] = originalBuffer[j + 2 + y * width * 4];
				convertedBuffer[i + 1 + y * width * 4] = originalBuffer[j + 1 + y * width * 4];
				convertedBuffer[i + 2 + y * width * 4] = originalBuffer[j + 0 + y * width * 4];
				convertedBuffer[i + 3 + y * width * 4] = originalBuffer[j + 3 + y * width * 4];
			}
		}
	break;
	
	case(3): // ABGR
		for (u32 y = 0; y < height; y++) {
			for (u32 i = 0, j = 0; j < width * 4; i += 4, j += 4) {
				convertedBuffer[i + 0 + y * width * 4] = originalBuffer[j + 1 + y * width * 4];
				convertedBuffer[i + 1 + y * width * 4] = originalBuffer[j + 2 + y * width * 4];
				convertedBuffer[i + 2 + y * width * 4] = originalBuffer[j + 3 + y * width * 4];
				convertedBuffer[i + 3 + y * width * 4] = originalBuffer[j + 0 + y * width * 4];
			}
		}
	break;
	}
	
	// Flip vertically
	if (flipv) {
		for (u32 y = 0; y < height / 2; y++) {
			for (u32 x = 0; x < width * 4; x++) {
				const u8 t = convertedBuffer[x + y * width * 4];
				convertedBuffer[x + y * width * 4] = convertedBuffer[x + (height - y - 1) * width * 4];
				convertedBuffer[x + (height - y - 1) * width * 4] = t;
			}
		}
	}

	QImage image = QImage(convertedBuffer, width, height, QImage::Format_ARGB32);
	if (image.isNull()) return;

	QLabel* canvas = new QLabel();
	canvas->setFixedSize(width, height);
	canvas->setPixmap(QPixmap::fromImage(image.scaled(width, height, Qt::KeepAspectRatio, Qt::SmoothTransformation)));

	QHBoxLayout* layout = new QHBoxLayout();
	layout->setContentsMargins(0, 0, 0, 0);
	layout->addWidget(canvas);

	QDialog* f_image_viewer = new QDialog(parent);
	f_image_viewer->setWindowTitle(qstr(fmt::format("Raw Image @ 0x%x", addr)));
	f_image_viewer->setFixedSize(QSize(width, height));
	f_image_viewer->setLayout(layout);
	f_image_viewer->show();
}
Ejemplo n.º 11
0
void QuestionWidget::init(QuestionItem *item, bool highlight_correct_answers)
{
    QHBoxLayout *mainhlayout = new QHBoxLayout(this);
    mainhlayout->setContentsMargins(6, 6, 6, 6);
    mainhlayout->setSpacing(6);
    QVBoxLayout *vlayout0 = new QVBoxLayout;
    vlayout0->setContentsMargins(0, 0, 0, 0);
    vlayout0->setSpacing(6);
    vlayout0->addStretch();
    qw_lbl_icon = new QLabel(this);
    qw_lbl_icon->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
    vlayout0->addWidget(qw_lbl_icon);
    qw_lbl_score = new QLabel(this);
    qw_lbl_score->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
    vlayout0->addWidget(qw_lbl_score);
    vlayout0->addStretch();
    mainhlayout->addLayout(vlayout0);
    mainhlayout->addSpacing(6);
    QVBoxLayout *vlayout = new QVBoxLayout;
    vlayout->setContentsMargins(0, 0, 0, 0);
    vlayout->setSpacing(6);
    qw_lbl_question = new QLabel(this);
    vlayout->addWidget(qw_lbl_question);
    qw_msw_svgs = new MTMultiSvgWidget(this);
    vlayout->addWidget(qw_msw_svgs);
    QHBoxLayout *hlayout = new QHBoxLayout;
    hlayout->setContentsMargins(0, 0, 0, 0);
    hlayout->setSpacing(6);
    QVBoxLayout *vlayout1 = new QVBoxLayout;
    vlayout1->setContentsMargins(0, 0, 0, 0);
    vlayout1->setSpacing(6);
    QVBoxLayout *vlayout2 = new QVBoxLayout;
    vlayout2->setContentsMargins(0, 0, 0, 0);
    vlayout2->setSpacing(6);
    for (int i = 0; i < item->numAnswers(); ++i) {
        QLabel *lbl = new QLabel(this);
        lbl->setWordWrap(true);
        if (item->numAnswers() % 2 == 0 ? i < item->numAnswers() / 2 : i <= item->numAnswers() / 2) {
            vlayout1->addWidget(lbl);
        } else {
            vlayout2->addWidget(lbl);
        }
        qw_lbl_answers << lbl;
    }
    if (item->numAnswers() % 2 != 0) {
        vlayout2->addStretch();
    }
    hlayout->addLayout(vlayout1);
    hlayout->addLayout(vlayout2);
    vlayout->addLayout(hlayout);
    qw_lbl_explanation = new QLabel(this);
    qw_lbl_explanation->setWordWrap(true);
    vlayout->addWidget(qw_lbl_explanation);
    mainhlayout->addLayout(vlayout);

    if (!item)
        return;
    qw_lbl_icon->setVisible(highlight_correct_answers);
    qw_lbl_icon->setPixmap(QPixmap(QString::fromUtf8(item->score() > 0.0 ? ":/images/images/button_ok.png" : ":/images/images/button_cancel.png")));
    qw_lbl_score->setVisible(highlight_correct_answers);
    qw_lbl_score->setText(tr("%1 out of %2").arg(item->score()).arg(item->maximumScore()));
    qw_lbl_question->setText(item->text());
    qw_lbl_explanation->setText(item->explanation());
    qw_lbl_explanation->setVisible(!item->explanation().isEmpty());
    QList<int> ans_order = item->answerOrder();
    QFont font;
    font.setPointSize(14);
    for (int i = 0; i < qw_lbl_answers.count(); ++i) {
        qw_lbl_answers.at(i)->setText(QString("%1 %2").arg(Question::indexToLabel(i + 1)).arg(item->answerAtIndex(ans_order.at(i) + 1)));
        font.setBold(item->isAnswerAtIndexCorrect(ans_order.at(i) + 1) && highlight_correct_answers);
        font.setUnderline(item->answered().testFlag(Question::indexToAnswer(ans_order.at(i) + 1)));
        qw_lbl_answers.at(i)->setFont(font);
    }
    for (int i = 0; i < item->numSvgItems(); ++i) {
        QSvgWidget *svg_widget = new QSvgWidget;
        svg_widget->load(item->svg(i).toUtf8());
        QSize svg_size = svg_widget->sizeHint();
        svg_size.scale(48, 48, Qt::KeepAspectRatioByExpanding);
        svg_widget->setMinimumSize(svg_size);
        svg_widget->setMaximumSize(svg_size);
        qw_msw_svgs->addWidget(svg_widget, item->svgName(i), false);
    }
    if (item->numSvgItems() < 1) {
        qw_msw_svgs->setVisible(false);
    }
}
Ejemplo n.º 12
0
KnobGuiPtr
DockablePanelPrivate::findKnobGuiOrCreate(const KnobPtr & knob,
                                          bool makeNewLine,
                                          QWidget* lastRowWidget,
                                          const std::vector< boost::shared_ptr< KnobI > > & knobsOnSameLine)
{
    assert(knob);
    boost::shared_ptr<KnobGroup> isGroup = boost::dynamic_pointer_cast<KnobGroup>(knob);
    boost::shared_ptr<KnobPage> isPage = boost::dynamic_pointer_cast<KnobPage>(knob);
    for (KnobsGuiMapping::const_iterator it = _knobs.begin(); it != _knobs.end(); ++it) {
        if ( (it->first.lock() == knob) && it->second ) {
            if (isPage) {
                return it->second;
            } else if ( isGroup && ( ( !isGroup->isTab() && it->second->hasWidgetBeenCreated() ) || isGroup->isTab() ) ) {
                return it->second;
            } else if ( it->second->hasWidgetBeenCreated() ) {
                return it->second;
            } else {
                break;
            }
        }
    }


    if (isPage) {
        if ( isPage->getChildren().empty() ) {
            return KnobGuiPtr();
        }
        getOrCreatePage(isPage);
        KnobsVec children = isPage->getChildren();
        initializeKnobVector(children, lastRowWidget);

        return KnobGuiPtr();
    }

    KnobGuiPtr ret = createKnobGui(knob);
    if (!ret) {
        return KnobGuiPtr();
    }

    KnobPtr parentKnob = knob->getParentKnob();
    boost::shared_ptr<KnobGroup> parentIsGroup = boost::dynamic_pointer_cast<KnobGroup>(parentKnob);
    KnobGuiGroup* parentGui = 0;
    /// if this knob is within a group, make sure the group is created so far
    if (parentIsGroup) {
        parentGui = dynamic_cast<KnobGuiGroup*>( findKnobGuiOrCreate( parentKnob, true, ret->getFieldContainer() ).get() );
    }

    ///So far the knob could have no parent, in which case we force it to be in the default page.
    if (!parentKnob) {
        boost::shared_ptr<KnobPage> defPage = ensureDefaultPageKnobCreated();
        defPage->addKnob(knob);
        parentKnob = defPage;
    }

    ///if widgets for the KnobGui have already been created, don't do the following
    ///For group only create the gui if it is not  a tab.
    if ( isGroup  && isGroup->isTab() ) {
        boost::shared_ptr<KnobPage> parentIsPage = boost::dynamic_pointer_cast<KnobPage>(parentKnob);
        if (!parentKnob || parentIsPage) {
            PageMap::iterator page = _pages.end();
            if (!parentKnob) {
                page = getDefaultPage(knob);
            } else {
                page = getOrCreatePage(parentIsPage);
            }
            bool existed = true;
            if (!page->second.groupAsTab) {
                existed = false;
                page->second.groupAsTab = new TabGroup(_publicInterface);
            }
            page->second.groupAsTab->addTab( isGroup, QString::fromUtf8( isGroup->getLabel().c_str() ) );

            ///retrieve the form layout
            QGridLayout* layout;
            if (_useScrollAreasForTabs) {
                layout = dynamic_cast<QGridLayout*>( dynamic_cast<QScrollArea*>(page->second.tab)->widget()->layout() );
            } else {
                layout = dynamic_cast<QGridLayout*>( page->second.tab->layout() );
            }
            assert(layout);
            if (!existed) {
                layout->addWidget(page->second.groupAsTab, page->second.currentRow, 0, 1, 2);
            }

            page->second.groupAsTab->refreshTabSecretNess( isGroup.get() );
        } else {
            assert(parentIsGroup);
            assert(parentGui);
            TabGroup* groupAsTab = parentGui->getOrCreateTabWidget();

            groupAsTab->addTab( isGroup, QString::fromUtf8( isGroup->getLabel().c_str() ) );

            if ( parentIsGroup && parentIsGroup->isTab() ) {
                ///insert the tab in the layout of the parent
                ///Find the page in the parentParent group
                KnobPtr parentParent = parentKnob->getParentKnob();
                assert(parentParent);
                boost::shared_ptr<KnobGroup> parentParentIsGroup = boost::dynamic_pointer_cast<KnobGroup>(parentParent);
                boost::shared_ptr<KnobPage> parentParentIsPage = boost::dynamic_pointer_cast<KnobPage>(parentParent);
                assert(parentParentIsGroup || parentParentIsPage);
                TabGroup* parentTabGroup = 0;
                if (parentParentIsPage) {
                    PageMap::iterator page = getOrCreatePage(parentParentIsPage);
                    assert( page != _pages.end() );
                    parentTabGroup = page->second.groupAsTab;
                } else {
                    KnobsGuiMapping::iterator it = findKnobGui(parentParent);
                    assert( it != _knobs.end() );
                    KnobGuiGroup* parentParentGroupGui = dynamic_cast<KnobGuiGroup*>( it->second.get() );
                    assert(parentParentGroupGui);
                    parentTabGroup = parentParentGroupGui->getOrCreateTabWidget();
                }

                QGridLayout* layout = parentTabGroup->addTab( parentIsGroup, QString::fromUtf8( parentIsGroup->getLabel().c_str() ) );
                assert(layout);
                layout->addWidget(groupAsTab, 0, 0, 1, 2);
            } else {
                boost::shared_ptr<KnobPage> topLevelPage = knob->getTopLevelPage();
                PageMap::iterator page = getOrCreatePage(topLevelPage);
                assert( page != _pages.end() );
                ///retrieve the form layout
                QGridLayout* layout;
                if (_useScrollAreasForTabs) {
                    layout = dynamic_cast<QGridLayout*>(
                        dynamic_cast<QScrollArea*>(page->second.tab)->widget()->layout() );
                } else {
                    layout = dynamic_cast<QGridLayout*>( page->second.tab->layout() );
                }
                assert(layout);

                layout->addWidget(groupAsTab, page->second.currentRow, 0, 1, 2);
            }
            groupAsTab->refreshTabSecretNess( isGroup.get() );
        }
    } else if ( !ret->hasWidgetBeenCreated() ) {
        KnobPtr parentKnobTmp = parentKnob;
        while (parentKnobTmp) {
            KnobPtr parent = parentKnobTmp->getParentKnob();
            if (!parent) {
                break;
            } else {
                parentKnobTmp = parent;
            }
        }

        ////find in which page the knob should be
        boost::shared_ptr<KnobPage> isTopLevelParentAPage = boost::dynamic_pointer_cast<KnobPage>(parentKnobTmp);
        assert(isTopLevelParentAPage);

        PageMap::iterator page = getOrCreatePage(isTopLevelParentAPage);
        assert( page != _pages.end() );

        ///retrieve the form layout
        QGridLayout* layout;
        if (_useScrollAreasForTabs) {
            layout = dynamic_cast<QGridLayout*>(
                dynamic_cast<QScrollArea*>(page->second.tab)->widget()->layout() );
        } else {
            layout = dynamic_cast<QGridLayout*>( page->second.tab->layout() );
        }
        assert(layout);


        ///if the knob has specified that it didn't want to trigger a new line, decrement the current row
        /// index of the tab

        if (!makeNewLine) {
            --page->second.currentRow;
        }

        QWidget* fieldContainer = 0;
        QHBoxLayout* fieldLayout = 0;

        if (makeNewLine) {
            ///if new line is not turned off, create a new line
            fieldContainer = new QWidget(page->second.tab);
            fieldLayout = new QHBoxLayout(fieldContainer);
            fieldLayout->setContentsMargins( TO_DPIX(3), 0, 0, TO_DPIY(NATRON_SETTINGS_VERTICAL_SPACING_PIXELS) );
            fieldLayout->setSpacing( TO_DPIY(2) );
            fieldLayout->setAlignment(Qt::AlignLeft);
        } else {
            ///otherwise re-use the last row's widget and layout
            assert(lastRowWidget);
            fieldContainer = lastRowWidget;
            fieldLayout = dynamic_cast<QHBoxLayout*>( fieldContainer->layout() );
        }

        assert(fieldContainer);
        assert(fieldLayout);

        ///Create the label if needed
        KnobClickableLabel* label = 0;
        Label* warningLabel = 0;
        std::string descriptionLabel;
        KnobString* isStringKnob = dynamic_cast<KnobString*>( knob.get() );
        bool isLabelKnob = isStringKnob && isStringKnob->isLabel();
        if (isLabelKnob) {
            descriptionLabel = isStringKnob->getValue();
        } else {
            descriptionLabel = knob->getLabel();
        }
        const std::string& labelIconFilePath = knob->getIconLabel();
        QWidget *labelContainer = 0;
        QHBoxLayout *labelLayout = 0;
        const bool hasLabel = ret->isLabelVisible() || isLabelKnob;
        if (hasLabel) {
            if (makeNewLine) {
                labelContainer = new QWidget(page->second.tab);
                labelLayout = new QHBoxLayout(labelContainer);
                labelLayout->setContentsMargins( TO_DPIX(3), 0, 0, TO_DPIY(NATRON_SETTINGS_VERTICAL_SPACING_PIXELS) );
                labelLayout->setSpacing( TO_DPIY(2) );
            }

            label = new KnobClickableLabel(QString(), ret, page->second.tab);
            warningLabel = new Label(page->second.tab);
            warningLabel->setVisible(false);
            QFontMetrics fm(label->font(), 0);
            int pixSize = fm.height();
            QPixmap stdErrorPix;
            stdErrorPix = getStandardIcon(QMessageBox::Critical, pixSize, label);
            warningLabel->setPixmap(stdErrorPix);

            bool pixmapSet = false;
            if ( !labelIconFilePath.empty() ) {
                QPixmap pix;

                if (labelIconFilePath == "dialog-warning") {
                    pix = getStandardIcon(QMessageBox::Warning, pixSize, label);
                } else if (labelIconFilePath == "dialog-question") {
                    pix = getStandardIcon(QMessageBox::Question, pixSize, label);
                } else if (labelIconFilePath == "dialog-error") {
                    pix = stdErrorPix;
                } else if (labelIconFilePath == "dialog-information") {
                    pix = getStandardIcon(QMessageBox::Information, pixSize, label);
                } else {
                    pix.load( QString::fromUtf8( labelIconFilePath.c_str() ) );
                    if (pix.width() != pixSize) {
                        pix = pix.scaled(pixSize, pixSize, Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
                    }
                }
                if ( !pix.isNull() ) {
                    pixmapSet = true;
                    label->setPixmap(pix);
                }
            }
            if (!pixmapSet) {
                QString labelStr( QString::fromUtf8( descriptionLabel.c_str() ) );
                /*labelStr += ":";*/
                if ( ret->isLabelBold() ) {
                    label->setBold(true);
                }
                label->setText_overload(labelStr );
            }
            QObject::connect( label, SIGNAL(clicked(bool)), ret.get(), SIGNAL(labelClicked(bool)) );


            if (makeNewLine) {
                labelLayout->addWidget(warningLabel);
                labelLayout->addWidget(label);
            }
        }

        /*
         * Find out in which layout the knob should be: either in the layout of the page or in the layout of
         * the nearest parent group tab in the hierarchy
         */
        boost::shared_ptr<KnobGroup> closestParentGroupTab;
        KnobPtr parentTmp = parentKnob;
        assert(parentKnobTmp);
        while (!closestParentGroupTab) {
            boost::shared_ptr<KnobGroup> parentGroup = boost::dynamic_pointer_cast<KnobGroup>(parentTmp);
            if ( parentGroup && parentGroup->isTab() ) {
                closestParentGroupTab = parentGroup;
            }
            parentTmp = parentTmp->getParentKnob();
            if (!parentTmp) {
                break;
            }
        }

        if (closestParentGroupTab) {
            /*
             * At this point we know that the parent group (which is a tab in the TabWidget) will have at least 1 knob
             * so ensure it is added to the TabWidget.
             * There are 2 possibilities, either the parent of the group tab is another group, in which case we have to
             * make sure the TabWidget is visible in the parent TabWidget of the group, otherwise we just add the TabWidget
             * to the on of the page.
             */

            KnobPtr parentParent = closestParentGroupTab->getParentKnob();
            KnobGroup* parentParentIsGroup = dynamic_cast<KnobGroup*>( parentParent.get() );
            boost::shared_ptr<KnobPage> parentParentIsPage = boost::dynamic_pointer_cast<KnobPage>(parentParent);

            assert(parentParentIsGroup || parentParentIsPage);
            if (parentParentIsGroup) {
                KnobGuiGroup* parentParentGroupGui = dynamic_cast<KnobGuiGroup*>( findKnobGuiOrCreate( parentParent, true,
                                                                                                       ret->getFieldContainer() ).get() );
                assert(parentParentGroupGui);
                if (parentParentGroupGui) {
                    TabGroup* groupAsTab = parentParentGroupGui->getOrCreateTabWidget();
                    assert(groupAsTab);
                    layout = groupAsTab->addTab( closestParentGroupTab, QString::fromUtf8( closestParentGroupTab->getLabel().c_str() ) );
                }
            } else if (parentParentIsPage) {
                PageMap::iterator page = getOrCreatePage(parentParentIsPage);
                assert( page != _pages.end() );
                assert(page->second.groupAsTab);
                layout = page->second.groupAsTab->addTab( closestParentGroupTab, QString::fromUtf8( closestParentGroupTab->getLabel().c_str() ) );
            }
            assert(layout);
        }

        ///fill the fieldLayout with the widgets
        ret->createGUI(layout, fieldContainer, labelContainer, label, warningLabel, fieldLayout, makeNewLine, knobsOnSameLine);


        ret->setEnabledSlot();

        ///Must add the row to the layout before calling setSecret()
        if (makeNewLine) {
            int rowIndex;
            if (closestParentGroupTab) {
                rowIndex = layout->rowCount();
            } else if ( parentGui && knob->isDynamicallyCreated() ) {
                const std::list<KnobGuiWPtr>& children = parentGui->getChildren();
                if ( children.empty() ) {
                    rowIndex = parentGui->getActualIndexInLayout();
                } else {
                    rowIndex = children.back().lock()->getActualIndexInLayout();
                }
                ++rowIndex;
            } else {
                rowIndex = page->second.currentRow;
            }


            const bool labelOnSameColumn = ret->isLabelOnSameColumn();


            if (!hasLabel) {
                layout->addWidget(fieldContainer, rowIndex, 0, 1, 2);
            } else {
                if (label) {
                    if (labelOnSameColumn) {
                        labelLayout->addWidget(fieldContainer);
                        layout->addWidget(labelContainer, rowIndex, 0, 1, 2);
                    } else {
                        layout->addWidget(labelContainer, rowIndex, 0, 1, 1, Qt::AlignRight);
                        layout->addWidget(fieldContainer, rowIndex, 1, 1, 1);
                    }
                }
            }


            //if (closestParentGroupTab) {
            ///See http://stackoverflow.com/questions/14033902/qt-qgridlayout-automatically-centers-moves-items-to-the-middle for
            ///a bug of QGridLayout: basically all items are centered, but we would like to add stretch in the bottom of the layout.
            ///To do this we add an empty widget with an expanding vertical size policy.
            /*QWidget* foundSpacer = 0;
               for (int i = 0; i < layout->rowCount(); ++i) {
                QLayoutItem* item = layout->itemAtPosition(i, 0);
                if (!item) {
                    continue;
                }
                QWidget* w = item->widget();
                if (!w) {
                    continue;
                }
                if (w->objectName() == QString::fromUtf8("emptyWidget")) {
                    foundSpacer = w;
                    break;
                }
               }
               if (foundSpacer) {
                layout->removeWidget(foundSpacer);
               } else {
                foundSpacer = new QWidget(layout->parentWidget());
                foundSpacer->setObjectName(QString::fromUtf8("emptyWidget"));
                foundSpacer->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding);

               }

               ///And add our stretch
               layout->addWidget(foundSpacer,layout->rowCount(), 0, 1, 2);*/
            // }
        } // makeNewLine

        ret->setSecret();

        if ( knob->isNewLineActivated() && ret->shouldAddStretch() ) {
            fieldLayout->addStretch();
        }


        ///increment the row count
        ++page->second.currentRow;

        if (parentIsGroup && parentGui) {
            parentGui->addKnob(ret);
        }
    } //  if ( !ret->hasWidgetBeenCreated() && ( !isGroup || !isGroup->isTab() ) ) {
Ejemplo n.º 13
0
AudioStatusBox::AudioStatusBox(ScServer *server, QWidget *parent):
    StatusBox(parent),
    mServer(server),
    m_avg_cpu(0.f),
    m_peak_cpu(0.f),
    m_ugens(0),
    m_synths(0),
    m_groups(0),
    m_synthdefs(0)
{
    mStatisticsLabel = new StatusLabel;
    mVolumeLabel = new StatusLabel;
    mMuteLabel = new StatusLabel;
    mMuteLabel->setText("M");
    mRecordLabel = new StatusLabel;
    mRecordLabel->setText("R");

    QHBoxLayout *layout = new QHBoxLayout;
    layout->setContentsMargins(0,0,0,0);
    layout->setSpacing(1);
    layout->addWidget(mStatisticsLabel);
    layout->addWidget(mVolumeLabel);
    layout->addWidget(mMuteLabel);
    layout->addWidget(mRecordLabel);

    setLayout(layout);

    server->action(ScServer::Record)->setProperty("keep_menu_open", true);
    server->action(ScServer::VolumeRestore)->setProperty("keep_menu_open", true);
    server->action(ScServer::Mute)->setProperty("keep_menu_open", true);
    server->action(ScServer::DumpOSC)->setProperty("keep_menu_open", true);

    QAction *separator;
    addAction( server->action(ScServer::ToggleRunning) );
    addAction( server->action(ScServer::Reboot) );
    addAction( server->action(ScServer::KillAll) );
    addActionSeparator();
    addAction( server->action(ScServer::ShowMeters) );
    addAction( server->action(ScServer::ShowScope) );
    addAction( server->action(ScServer::ShowFreqScope) );
    addAction( server->action(ScServer::DumpNodeTree) );
    addAction( server->action(ScServer::DumpNodeTreeWithControls) );
    addAction( server->action(ScServer::PlotTree) );
	addAction( server->action(ScServer::DumpOSC) );
    addActionSeparator();
    addAction( server->action(ScServer::Record) );
    addActionSeparator();
    addAction( server->action(ScServer::VolumeRestore) );
    addAction( server->action(ScServer::Mute) );
    addAction( server->action(ScServer::Volume) );

    connect(server, SIGNAL(runningStateChange(bool,QString,int)),
            this, SLOT(onServerRunningChanged(bool,QString,int)));
    connect(server, SIGNAL(updateServerStatus(int,int,int,int,float,float)),
            this, SLOT(onServerStatusReply(int,int,int,int,float,float)));
    connect(server, SIGNAL(volumeChanged(float)), this, SLOT(updateVolumeLabel(float)));
    connect(server, SIGNAL(mutedChanged(bool)), this, SLOT(updateMuteLabel(bool)));
    connect(server, SIGNAL(recordingChanged(bool)), this, SLOT(updateRecordLabel(bool)));
    connect(server, SIGNAL(dumpOSCChanged(bool)), this, SLOT(updateDumpOSCLabel(bool)));

    onServerRunningChanged(false, "", 0);
    updateVolumeLabel( mServer->volume() );
    updateMuteLabel( mServer->isMuted() );
    updateRecordLabel( mServer->isRecording() );
}
QgsSingleBandPseudoColorRendererWidget::QgsSingleBandPseudoColorRendererWidget( QgsRasterLayer* layer, const QgsRectangle &extent )
    : QgsRasterRendererWidget( layer, extent )
    , mMinMaxWidget( NULL )
    , mMinMaxOrigin( 0 )
{
  QSettings settings;

  setupUi( this );

  mColormapTreeWidget->setColumnWidth( 1, 50 );

  QString defaultPalette = settings.value( "/Raster/defaultPalette", "Spectral" ).toString();

  mColorRampComboBox->populate( QgsStyleV2::defaultStyle() );

  QgsDebugMsg( "defaultPalette = " + defaultPalette );
  mColorRampComboBox->setCurrentIndex( mColorRampComboBox->findText( defaultPalette ) );

  if ( !mRasterLayer )
  {
    return;
  }

  QgsRasterDataProvider* provider = mRasterLayer->dataProvider();
  if ( !provider )
  {
    return;
  }

  // Must be before adding items to mBandComboBox (signal)
  mMinLineEdit->setValidator( new QDoubleValidator( mMinLineEdit ) );
  mMaxLineEdit->setValidator( new QDoubleValidator( mMaxLineEdit ) );

  mMinMaxWidget = new QgsRasterMinMaxWidget( layer, this );
  mMinMaxWidget->setExtent( extent );
  QHBoxLayout *layout = new QHBoxLayout();
  layout->setContentsMargins( 0, 0, 0, 0 );
  mMinMaxContainerWidget->setLayout( layout );
  layout->addWidget( mMinMaxWidget );
  connect( mMinMaxWidget, SIGNAL( load( int, double, double, int ) ),
           this, SLOT( loadMinMax( int, double, double, int ) ) );


  //fill available bands into combo box
  int nBands = provider->bandCount();
  for ( int i = 1; i <= nBands; ++i ) //band numbering seem to start at 1
  {
    mBandComboBox->addItem( displayBandName( i ), i );
  }

  mColorInterpolationComboBox->addItem( tr( "Discrete" ), 0 );
  mColorInterpolationComboBox->addItem( tr( "Linear" ), 1 );
  mColorInterpolationComboBox->addItem( tr( "Exact" ), 2 );
  mColorInterpolationComboBox->setCurrentIndex( 1 );
  mClassificationModeComboBox->addItem( tr( "Continuous" ), Continuous );
  mClassificationModeComboBox->addItem( tr( "Equal interval" ), EqualInterval );
  //quantile would be nice as well

  mNumberOfEntriesSpinBox->setValue( 5 ); // some default

  setFromRenderer( layer->renderer() );

  // If there is currently no min/max, load default with user current default options
  if ( mMinLineEdit->text().isEmpty() || mMaxLineEdit->text().isEmpty() )
  {
    mMinMaxWidget->load();
  }

  on_mClassificationModeComboBox_currentIndexChanged( 0 );

  resetClassifyButton();
}
Ejemplo n.º 15
0
AddLayerModelWidget::AddLayerModelWidget(SlotInspectorSection* parentSlot) :
    QWidget {parentSlot}
{
    QHBoxLayout* layout = new QHBoxLayout;
    layout->setContentsMargins(0, 0, 0 , 0);
    this->setLayout(layout);

    // Button
    QToolButton* addButton = new QToolButton;
    addButton->setText("+");

    // Text
    auto addText = new QLabel("Add Process View");
    addText->setStyleSheet(QString("text-align : left;"));

    layout->addWidget(addButton);
    layout->addWidget(addText);

    connect(addButton, &QToolButton::pressed,
            [ = ]()
    {
        QStringList available_models;

        // 1. List the processes in the model.
        const auto& shared_process_list = parentSlot->model().parentConstraint().processes;

        // 2. List the processes that already have a view in this slot
        const auto& already_displayed_processes = parentSlot->model().layers;

        // 3. Compute the difference
        for(const auto& process : shared_process_list)
        {
            auto beg_it = already_displayed_processes.cbegin();
            auto end_it = already_displayed_processes.cend();
            auto it = std::find_if(beg_it,
                                   end_it,
                                   [&process](const LayerModel& lm)
            { return lm.processModel().id() == process.id(); });

            if(it == end_it)
            {
                available_models += QString::number(*process.id().val());
            }
        }

        // 4. Present a dialog with the availble id's
        if(available_models.size() > 0)
        {
            bool ok = false;
            auto process_name =
                    QInputDialog::getItem(
                        this,
                        QObject::tr("Choose a process id"),
                        QObject::tr("Choose a process id"),
                        available_models,
                        0,
                        false,
                        &ok);

            if(ok)
                parentSlot->createLayerModel(Id<Process> {process_name.toInt() });
        }
    });
}
Ejemplo n.º 16
0
CreateGroup::CreateGroup(QStringList items, QWidget *parent)
    : THWidgetBase(parent)
{
    setAttribute(Qt::WA_DeleteOnClose);
    setFixedSize(380, 250);
    setTitleBarWidth(380);
    setWindowFlags(Qt::FramelessWindowHint | Qt::Tool);
    setWindowModality(Qt::ApplicationModal);
    bar->setBarButtons(HappyTitleBar::MinButtonHint);
    bar->setBarButtons(HappyTitleBar::MaxButtonHint);
    bar->setExtraButtonVisible(false);
    bar->setBarIcon(":res/happy.png");
    bar->setBarContent(cn("创建群/讨论组"));
    connect(bar, &HappyTitleBar::signalClose, this, [=] () {
            this->close();
    });

    QVBoxLayout *v= new QVBoxLayout();
    v->setContentsMargins(0, 0, 0, 0);
    QHBoxLayout *h = new QHBoxLayout();
    h->setContentsMargins(0, 0, 0, 0);
    QVBoxLayout *v1= new QVBoxLayout();
    v1->setContentsMargins(0, 0, 0, 0);
    QVBoxLayout *v2= new QVBoxLayout();
    v2->setContentsMargins(0, 0, 0, 0);

    EmojiLabel *photo = new EmojiLabel(this);
    photo->setMoiveRes(":res/ui3/default_group_create.gif");
    photo->setMovieable(true);
    photo->setFixedSize(70, 70);
    photo->setStyleSheet(cns("QLabel{border-width:1px;border-style:solid;border-radius:3px;border-color:transparent;"
                             "background:transparent;}"
                             "QLabel:hover{border-width:1px;border-style:solid;border-radius:3px;border-color:white;}"
                             "QLabel:pressed{border-width:1px;border-style:solid;border-radius:3px;border-color:rgba(240,240,240,50);}"));
    QLabel *lbl1 = new QLabel(cn("修改群图片(点击)"), this);
    lbl1->setStyleSheet(QStringLiteral("font-family:微软雅黑;font:12px;color:white;"));
    QPushButton *pb1 = new QPushButton(cn("从表情库中选择"), this);
    pb1->setFixedWidth(120);
    v1->addWidget(photo, 8, Qt::AlignCenter);
    v1->addWidget(lbl1,  1, Qt::AlignCenter);
    v1->addWidget(pb1,  1, Qt::AlignCenter);

    QLineEdit *edit1 = new QLineEdit(this);
    edit1->setAlignment(Qt::AlignCenter);
    edit1->setFixedWidth(180);
    edit1->setPlaceholderText(cn("输入群/讨论组名称"));

    QLineEdit *edit2 = new QLineEdit(this);
    edit2->setText(cn("讨论组"));
    edit2->setReadOnly(true);
    edit2->setAlignment(Qt::AlignCenter);
    edit2->setFixedWidth(180);
    edit2->setPlaceholderText(cn("选择属性"));

    HappyTextEdit *edit3 = new HappyTextEdit(this);
    edit3->setPlaceholderText(cn("写点什么吧,这群是干啥的"));
    edit3->setFixedWidth(180);

    v2->addWidget(edit1, 1, Qt::AlignCenter);
    v2->addWidget(edit2, 1, Qt::AlignCenter);
    v2->addWidget(edit3, 8, Qt::AlignCenter);

    h->addLayout(v1, 2);
    h->addLayout(v2, 3);

    QHBoxLayout *h1 = new QHBoxLayout();
    h1->setContentsMargins(55, 0, 0, 10);
    QPushButton *selectPb = new QPushButton(cn("选择成员"), this);
    selectPb->setCheckable(true);
    selectPb->setFixedWidth(70);
    QPushButton *confirmPb = new QPushButton(cn("确定"), this);
    confirmPb->setFixedWidth(50);
    QPushButton *cancelPb = new QPushButton(cn("取消"), this);
    cancelPb->setFixedWidth(50);
    h1->addStretch(7);
    h1->addWidget(selectPb);
    h1->addWidget(confirmPb);
    h1->addWidget(cancelPb);
    h1->addStretch(1);

    v->addLayout(h, 9);
    v->addLayout(h1, 1);

    QHBoxLayout *h2 = new QHBoxLayout(this);
    h2->setContentsMargins(5, 35, 5, 10);
    CheckList *list = new CheckList(this);
    list->setFixedSize(120, 195);
    list->setVisible(false);
    h2->addLayout(v, 5);
    h2->addWidget(list, 1, Qt::AlignHCenter | Qt::AlignTop);
    h2->addSpacing(15);


    QFile file;
    file.setFileName(":res/css/lineedit.css");
    if (file.open(QIODevice::ReadOnly))
    {
        QByteArray ba = file.readAll();
        edit1->setStyleSheet(QTextCodec::codecForLocale()->toUnicode(ba));
        edit2->setStyleSheet(QTextCodec::codecForLocale()->toUnicode(ba));
    }
    file.close();
    file.setFileName(":res/css/button2.css");
    if (file.open(QIODevice::ReadOnly))
    {
        QByteArray ba = file.readAll();
        pb1->setStyleSheet(QTextCodec::codecForLocale()->toUnicode(ba));
        selectPb->setStyleSheet(QTextCodec::codecForLocale()->toUnicode(ba));
        confirmPb->setStyleSheet(QTextCodec::codecForLocale()->toUnicode(ba));
        cancelPb->setStyleSheet(QTextCodec::codecForLocale()->toUnicode(ba));
    }
    file.close();
    file.setFileName(":res/css/list2.css");
    if (file.open(QIODevice::ReadOnly))
    {
        QByteArray ba = file.readAll();
        list->setStyleSheet(QTextCodec::codecForLocale()->toUnicode(ba));
    }
    file.close();

    // load data
    ConfigureData *conf = ConfigureData::getInstance();
    updateColor(conf->getColorIni("color1"), conf->getColorIni("color2"));
    list->setmyuid(conf->getUuid());
    list->addCheckItems(items);

    connect(confirmPb, &QPushButton::clicked, this, [=] () {
        QString name = edit1->text();
        if (name.trimmed().isEmpty())
        {
            MsgBox::ShowMsgBox(cn("错误"),
                               cn("不能使用空的名称"),
                               cn("确定"));
            return;
        }
        QString attr = edit2->text();
        QString des = edit3->toPlainText();
        if (des.trimmed().isEmpty())
        {
            int rlt = MsgBox::ShowMsgBox(cn("提示"),
                               cn("真的不写点什么?"),
                               cn("不写了"), cn("那写点"));
            if (rlt != 0)
                return;
        }
        QString uids = list->checkedids();
        if (uids.split(";").size() <= 1)
        {
            int rlt = MsgBox::ShowMsgBox(cn("提示"),
                               cn("这个组里面只有你一个人\n"
                                  "确定创建这个寂寞的群组么?"),
                               cn("确定"), cn("去选人"));
            if (rlt == 1)
            {
                selectPb->setChecked(true);
                return;
            }

        }
        // check image
        QString newPhotoName = photo->ImagePath();
        QString path = GetWorkPath() + "/face";
        if (QDir().mkpath(path))
        {
            QFile file;
            file.setFileName(newPhotoName);
            if (file.exists())
            {
                QString temp = path + "/" + QFileInfo(newPhotoName).fileName();
                if (QFile::exists(temp))
                {
                    newPhotoName = temp;
                }
                else
                {
                    bool b = file.copy(temp);
                    if (b)
                        newPhotoName = temp;
                }
            }
            file.close();
        }

        // 创建数据
        GroupData gd;
        gd.setName(name);
        gd.setAttr(attr);
        gd.setGroupdescribe(des);
        gd.setPhoto(newPhotoName);
        gd.setGroupmember(uids);
        gd.setUid(getUuid());
        gd.setDeleteable(true);
        gd.setEditable(true);
        QDateTime dt = QDateTime::currentDateTime();
        gd.setCreationtime(dt.toString("yyyy-MM-dd hh:mm:ss"));
        gd.setUpdatetime(dt.toTime_t());
        gd.setCreator(conf->getIni("nickname"));
        gd.setPort(qrand() % 10000 + 20000);
        gd.setNetmask(createNetmask());
        emit confrimCreate(gd);
        close();
    });
    connect(cancelPb, &QPushButton::clicked, this, [=] () {
        emit bar->signalClose();
    });

    connect(selectPb, &QPushButton::toggled, this, [=] (bool b) {
        if (b)
        {
            setFixedWidth(480);
            setTitleBarWidth(480);
        }
        else
        {
            setFixedWidth(380);
            setTitleBarWidth(380);
        }
        list->setVisible(b);
    });

    connect(this, &CreateGroup::updateItems,
            list, &CheckList::addCheckItems);

    connect(pb1, &QPushButton::clicked, this, [=] () {
        EmotionsBox *box = EmotionsBox::GetInstance();
        box->show();
        box->activateWindow();
        QPoint p = QCursor::pos();
        box->move(p.x() - box->width() / 2, p.y() - 20 - box->height());
        connect(box, &EmotionsBox::select, this, [=] (QString str) {
            photo->setMoiveRes(str);
        });
        connect(box, &EmotionsBox::signalHide, this, [=] () {
            disconnect(box, &EmotionsBox::signalHide, 0, 0);
            disconnect(box, &EmotionsBox::select, 0, 0);
        });
    });
    connect(photo, &EmojiLabel::clicked,
            this, [=] () {
        QString filter = cns("图片资源(*.jpg *.gif *.png*.bmp);;全部文件(*.*)");
        QString path = QFileDialog::getOpenFileName(this, QStringLiteral("选择图片"),
                                                    ".", filter);
        if (!QFileInfo(path).isFile() && !QImageReader(path).canRead())
        {
            MsgBox::ShowMsgBox(cn("错误"),
                               cn("不是有效的文件"),
                               cn("确定"));
            return;
        }
        photo->setMoiveRes(path);
    });
}
Ejemplo n.º 17
0
/*
=======================================
    WinMain 程序入口
=======================================
*/
int WINAPI
WinMain (
  __CR_IN__ HINSTANCE   curt_app,
  __CR_IN__ HINSTANCE   prev_app,
  __CR_IN__ LPSTR       cmd_line,
  __CR_IN__ int         cmd_show
    )
{
    uint_t      argc;
    ansi_t**    argv;

    CR_NOUSE(prev_app);
    CR_NOUSE(cmd_show);

    /* 只允许一个例程 */
    if (misc_is_running(EXE_XNAME))
        return (QST_ERROR);

    /* 建立 CrHack 系统 */
    if (!set_app_type(CR_APP_GUI))
        return (QST_ERROR);
    mem_zero(&s_wrk_ctx, sizeof(s_wrk_ctx));

    int qt_argc;

    /* 获取命令行参数, 不包括进程文件名 */
    argv = misc_get_param(cmd_line, &argc);
    qt_argc = (int)argc;

    QApplication    qt_app(qt_argc, argv);

    qt_app.setApplicationName("QstComm");
    qt_app.setOrganizationName("QuestLAB");

    sint_t  x1, y1;
    uint_t  ww, hh;

    /* 生成一个可变大小的窗口 */
    mtlock_init(&s_wrk_ctx.lock);
    qst_load_cfg(&s_wrk_ctx.cfgs);
    misc_desk_init(WIN_ICONF, &x1, &y1, &ww, &hh,
                   QCOM_DEF_WIDTH, QCOM_DEF_HEIGHT);
    if (ww < QCOM_DEF_WIDTH)  ww = QCOM_DEF_WIDTH;
    if (hh < QCOM_DEF_HEIGHT) hh = QCOM_DEF_HEIGHT;

    RECT            w_rect;
    sint_t          fw, fh;
    QMainWindow     qt_win;

    /* Qt 里的宽高都不包括边框
       需要自己用 Win32 API 获取 */
    qt_win.setWindowFlags(qt_win.windowFlags()
        & (~Qt::WindowMaximizeButtonHint));
    qt_win.move(x1, y1);
    qt_win.resize(ww, hh);
    s_wrk_ctx.hwnd = (HWND)qt_win.winId();
    if (!GetWindowRect(s_wrk_ctx.hwnd, &w_rect))
        return (QST_ERROR);
    fw = w_rect.right - w_rect.left - ww;
    fh = w_rect.bottom - w_rect.top - hh;
    qt_win.setMinimumSize(QCOM_DEF_WIDTH  - fw,
                          QCOM_DEF_HEIGHT - fh);
    qt_win.resize(ww - fw, hh - fh);

    QWidget*        cent = new QWidget (&qt_win);
    CTextEdit*      edit = new CTextEdit (cent);
    QHBoxLayout*    hori = new QHBoxLayout (cent);

    /* 创建窗体里的控件 */
    hori->setSpacing(6);
    hori->setContentsMargins(8, 8, 8, 8);
    hori->addWidget(edit);
    qt_win.setCentralWidget(cent);

    CTextOper   oper(&qt_win, edit);

    s_wrk_ctx.oper = (void_t*)(&oper);
    SetClassLongPtr(s_wrk_ctx.hwnd, GCLP_HICON, (LONG_PTR)
                    LoadIconA(curt_app, (ansi_t*)101));

    /* 初始化 ANSI 上下文 */
    if (!qst_csi_init())
        return (QST_ERROR);
    qst_set_viewer(&s_wrk_ctx);

    /* 初始化网络 */
    if (!socket_init())
        return (QST_ERROR);
    s_wrk_ctx.netw = netw_cli_open(EXE_XNAME);
    if (s_wrk_ctx.netw == NULL)
        return (QST_ERROR);

    /* 读取需要超时, 不然线程无法退出 */
    socket_set_timeout(s_wrk_ctx.netw, -1, QST_TCP_TOUT);

    thrd_t  thrd;

    /* 生成工作线程 */
    s_wrk_ctx.quit = FALSE;
    s_wrk_ctx.comm.quit = FALSE;
    s_wrk_ctx.comm.text = TRUE;
    s_wrk_ctx.comm.rtype = "text";
    s_wrk_ctx.comm.stype = "text";
    s_wrk_ctx.comm.title = NULL;
    s_wrk_ctx.comm.render = qst_txt_show;
    s_wrk_ctx.page = get_sys_codepage();
    qst_update_title(&s_wrk_ctx);
    thrd = thread_new(0, qst_com_main, &s_wrk_ctx, FALSE);
    if (thrd == NULL)
        return (QST_ERROR);
    sio_init();

    /* 开始 Qt 流程 */
    qt_win.show();
    qt_app.exec();

    /* 关闭线程直接退出 */
    if (!s_wrk_ctx.quit)
        s_wrk_ctx.quit = TRUE;
    thread_wait(thrd);
    thread_del(thrd);
    netw_cli_close(s_wrk_ctx.netw);
    sio_free();
    qst_csi_free();
    return (QST_OKAY);
}
Ejemplo n.º 18
0
BitcoinGUI::BitcoinGUI(const PlatformStyle *_platformStyle, const NetworkStyle *networkStyle, QWidget *parent) :
    QMainWindow(parent),
    enableWallet(false),
    clientModel(0),
    walletFrame(0),
    unitDisplayControl(0),
    labelWalletEncryptionIcon(0),
    labelWalletHDStatusIcon(0),
    connectionsControl(0),
    labelBlocksIcon(0),
    progressBarLabel(0),
    progressBar(0),
    progressDialog(0),
    appMenuBar(0),
    overviewAction(0),
    historyAction(0),
    quitAction(0),
    sendCoinsAction(0),
    sendCoinsMenuAction(0),
    usedSendingAddressesAction(0),
    usedReceivingAddressesAction(0),
    signMessageAction(0),
    verifyMessageAction(0),
    aboutAction(0),
    receiveCoinsAction(0),
    receiveCoinsMenuAction(0),
    optionsAction(0),
    toggleHideAction(0),
    encryptWalletAction(0),
    backupWalletAction(0),
    changePassphraseAction(0),
    aboutQtAction(0),
    openRPCConsoleAction(0),
    openAction(0),
    showHelpMessageAction(0),
    trayIcon(0),
    trayIconMenu(0),
    notificator(0),
    rpcConsole(0),
    helpMessageDialog(0),
    modalOverlay(0),
    prevBlocks(0),
    spinnerFrame(0),
    platformStyle(_platformStyle)
{
    QSettings settings;
    if (!restoreGeometry(settings.value("MainWindowGeometry").toByteArray())) {
        // Restore failed (perhaps missing setting), center the window
        move(QApplication::desktop()->availableGeometry().center() - frameGeometry().center());
    }

    QString windowTitle = tr(PACKAGE_NAME) + " - ";
#ifdef ENABLE_WALLET
    enableWallet = WalletModel::isWalletEnabled();
#endif // ENABLE_WALLET
    if(enableWallet)
    {
        windowTitle += tr("Wallet");
    } else {
        windowTitle += tr("Node");
    }
    windowTitle += " " + networkStyle->getTitleAddText();
#ifndef Q_OS_MAC
    QApplication::setWindowIcon(networkStyle->getTrayAndWindowIcon());
    setWindowIcon(networkStyle->getTrayAndWindowIcon());
#else
    MacDockIconHandler::instance()->setIcon(networkStyle->getAppIcon());
#endif
    setWindowTitle(windowTitle);

#if defined(Q_OS_MAC) && QT_VERSION < 0x050000
    // This property is not implemented in Qt 5. Setting it has no effect.
    // A replacement API (QtMacUnifiedToolBar) is available in QtMacExtras.
    setUnifiedTitleAndToolBarOnMac(true);
#endif

    rpcConsole = new RPCConsole(_platformStyle, 0);
    helpMessageDialog = new HelpMessageDialog(this, false);
#ifdef ENABLE_WALLET
    if(enableWallet)
    {
        /** Create wallet frame and make it the central widget */
        walletFrame = new WalletFrame(_platformStyle, this);
        setCentralWidget(walletFrame);
    } else
#endif // ENABLE_WALLET
    {
        /* When compiled without wallet or -disablewallet is provided,
         * the central widget is the rpc console.
         */
        setCentralWidget(rpcConsole);
    }

    // Accept D&D of URIs
    setAcceptDrops(true);

    // Create actions for the toolbar, menu bar and tray/dock icon
    // Needs walletFrame to be initialized
    createActions();

    // Create application menu bar
    createMenuBar();

    // Create the toolbars
    createToolBars();

    // Create system tray icon and notification
    createTrayIcon(networkStyle);

    // Create status bar
    statusBar();

    // Disable size grip because it looks ugly and nobody needs it
    statusBar()->setSizeGripEnabled(false);

    // Status bar notification icons
    QFrame *frameBlocks = new QFrame();
    frameBlocks->setContentsMargins(0,0,0,0);
    frameBlocks->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Preferred);
    QHBoxLayout *frameBlocksLayout = new QHBoxLayout(frameBlocks);
    frameBlocksLayout->setContentsMargins(3,0,3,0);
    frameBlocksLayout->setSpacing(3);
    unitDisplayControl = new UnitDisplayStatusBarControl(platformStyle);
    labelWalletEncryptionIcon = new QLabel();
    labelWalletHDStatusIcon = new QLabel();
    connectionsControl = new GUIUtil::ClickableLabel();
    labelBlocksIcon = new GUIUtil::ClickableLabel();
    if(enableWallet)
    {
        frameBlocksLayout->addStretch();
        frameBlocksLayout->addWidget(unitDisplayControl);
        frameBlocksLayout->addStretch();
        frameBlocksLayout->addWidget(labelWalletEncryptionIcon);
        frameBlocksLayout->addWidget(labelWalletHDStatusIcon);
    }
    frameBlocksLayout->addStretch();
    frameBlocksLayout->addWidget(connectionsControl);
    frameBlocksLayout->addStretch();
    frameBlocksLayout->addWidget(labelBlocksIcon);
    frameBlocksLayout->addStretch();

    // Progress bar and label for blocks download
    progressBarLabel = new QLabel();
    progressBarLabel->setVisible(false);
    progressBar = new GUIUtil::ProgressBar();
    progressBar->setAlignment(Qt::AlignCenter);
    progressBar->setVisible(false);

    // Override style sheet for progress bar for styles that have a segmented progress bar,
    // as they make the text unreadable (workaround for issue #1071)
    // See https://qt-project.org/doc/qt-4.8/gallery.html
    QString curStyle = QApplication::style()->metaObject()->className();
    if(curStyle == "QWindowsStyle" || curStyle == "QWindowsXPStyle")
    {
        progressBar->setStyleSheet("QProgressBar { background-color: #e8e8e8; border: 1px solid grey; border-radius: 7px; padding: 1px; text-align: center; } QProgressBar::chunk { background: QLinearGradient(x1: 0, y1: 0, x2: 1, y2: 0, stop: 0 #FF8000, stop: 1 orange); border-radius: 7px; margin: 0px; }");
    }

    statusBar()->addWidget(progressBarLabel);
    statusBar()->addWidget(progressBar);
    statusBar()->addPermanentWidget(frameBlocks);

    // Install event filter to be able to catch status tip events (QEvent::StatusTip)
    this->installEventFilter(this);

    // Initially wallet actions should be disabled
    setWalletActionsEnabled(false);

    // Subscribe to notifications from core
    subscribeToCoreSignals();

    connect(connectionsControl, SIGNAL(clicked(QPoint)), this, SLOT(toggleNetworkActive()));

    modalOverlay = new ModalOverlay(this->centralWidget());
#ifdef ENABLE_WALLET
    if(enableWallet) {
        connect(walletFrame, SIGNAL(requestedSyncWarningInfo()), this, SLOT(showModalOverlay()));
        connect(labelBlocksIcon, SIGNAL(clicked(QPoint)), this, SLOT(showModalOverlay()));
        connect(progressBar, SIGNAL(clicked(QPoint)), this, SLOT(showModalOverlay()));
    }
#endif
}
Ejemplo n.º 19
0
void QmitkStdMultiWidgetEditor::CreateQtPartControl(QWidget* parent)
{
  if (d->m_StdMultiWidget == 0)
  {
    QHBoxLayout* layout = new QHBoxLayout(parent);
    layout->setContentsMargins(0,0,0,0);

    if (d->m_MouseModeToolbar == NULL)
    {
      d->m_MouseModeToolbar = new QmitkMouseModeSwitcher(parent); // delete by Qt via parent
      layout->addWidget(d->m_MouseModeToolbar);
    }

    berry::IPreferences::Pointer prefs = this->GetPreferences();

    mitk::BaseRenderer::RenderingMode::Type renderingMode = static_cast<mitk::BaseRenderer::RenderingMode::Type>(prefs->GetInt( "Rendering Mode" , 0 ));

    d->m_StdMultiWidget = new QmitkStdMultiWidget(parent,0,0,renderingMode);

    d->m_RenderWindows.insert("axial", d->m_StdMultiWidget->GetRenderWindow1());
    d->m_RenderWindows.insert("sagittal", d->m_StdMultiWidget->GetRenderWindow2());
    d->m_RenderWindows.insert("coronal", d->m_StdMultiWidget->GetRenderWindow3());
    d->m_RenderWindows.insert("3d", d->m_StdMultiWidget->GetRenderWindow4());

    d->m_MouseModeToolbar->setMouseModeSwitcher( d->m_StdMultiWidget->GetMouseModeSwitcher() );
    connect( d->m_MouseModeToolbar, SIGNAL( MouseModeSelected(mitk::MouseModeSwitcher::MouseMode) ),
      d->m_StdMultiWidget, SLOT( MouseModeSelected(mitk::MouseModeSwitcher::MouseMode) ) );

    layout->addWidget(d->m_StdMultiWidget);

    mitk::DataStorage::Pointer ds = this->GetDataStorage();

    // Tell the multiWidget which (part of) the tree to render
    d->m_StdMultiWidget->SetDataStorage(ds);

    // Initialize views as axial, sagittal, coronar to all data objects in DataStorage
    // (from top-left to bottom)
    mitk::TimeGeometry::Pointer geo = ds->ComputeBoundingGeometry3D(ds->GetAll());
    mitk::RenderingManager::GetInstance()->InitializeViews(geo);

    // Initialize bottom-right view as 3D view
    d->m_StdMultiWidget->GetRenderWindow4()->GetRenderer()->SetMapperID(
      mitk::BaseRenderer::Standard3D );

    // Enable standard handler for levelwindow-slider
    d->m_StdMultiWidget->EnableStandardLevelWindow();

    // Add the displayed views to the tree to see their positions
    // in 2D and 3D
    d->m_StdMultiWidget->AddDisplayPlaneSubTree();

    d->m_StdMultiWidget->EnableNavigationControllerEventListening();

    // Store the initial visibility status of the menu widget.
    d->m_MenuWidgetsEnabled = d->m_StdMultiWidget->IsMenuWidgetEnabled();

    this->GetSite()->GetPage()->AddPartListener(d->m_PartListener);

    this->OnPreferencesChanged(dynamic_cast<berry::IBerryPreferences*>(prefs.GetPointer()));

    this->RequestUpdate();
  }
}
Ejemplo n.º 20
0
LTMWindow::LTMWindow(Context *context) :
            GcChartWindow(context), context(context), dirty(true), stackDirty(true), compareDirty(true)
{
    useToToday = useCustom = false;
    plotted = DateRange(QDate(01,01,01), QDate(01,01,01));

    // the plot
    QVBoxLayout *mainLayout = new QVBoxLayout;
    ltmPlot = new LTMPlot(this, context, true);

    // the stack of plots
    QPalette palette;
    palette.setBrush(QPalette::Background, QBrush(GColor(CPLOTBACKGROUND)));

    plotsWidget = new QWidget(this);
    plotsWidget->setPalette(palette);
    plotsLayout = new QVBoxLayout(plotsWidget);
    plotsLayout->setSpacing(0);
    plotsLayout->setContentsMargins(0,0,0,0);

    plotArea = new QScrollArea(this);
#ifdef Q_OS_WIN
    QStyle *cde = QStyleFactory::create(OS_STYLE);
    plotArea->setStyle(cde);
#endif
    plotArea->setAutoFillBackground(false);
    plotArea->setWidgetResizable(true);
    plotArea->setWidget(plotsWidget);
    plotArea->setFrameStyle(QFrame::NoFrame);
    plotArea->setContentsMargins(0,0,0,0);
    plotArea->setPalette(palette);

    // the data table
    dataSummary = new QWebView(this);
    dataSummary->setContentsMargins(0,0,0,0);
    dataSummary->page()->view()->setContentsMargins(0,0,0,0);
    dataSummary->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
    dataSummary->setAcceptDrops(false);

    QFont defaultFont; // mainwindow sets up the defaults.. we need to apply
    dataSummary->settings()->setFontSize(QWebSettings::DefaultFontSize, defaultFont.pointSize()+1);
    dataSummary->settings()->setFontFamily(QWebSettings::StandardFont, defaultFont.family());

    // compare plot page
    compareplotsWidget = new QWidget(this);
    compareplotsWidget->setPalette(palette);
    compareplotsLayout = new QVBoxLayout(compareplotsWidget);
    compareplotsLayout->setSpacing(0);
    compareplotsLayout->setContentsMargins(0,0,0,0);

    compareplotArea = new QScrollArea(this);
#ifdef Q_OS_WIN
    cde = QStyleFactory::create(OS_STYLE);
    compareplotArea->setStyle(cde);
#endif
    compareplotArea->setAutoFillBackground(false);
    compareplotArea->setWidgetResizable(true);
    compareplotArea->setWidget(compareplotsWidget);
    compareplotArea->setFrameStyle(QFrame::NoFrame);
    compareplotArea->setContentsMargins(0,0,0,0);
    compareplotArea->setPalette(palette);

    // the stack
    stackWidget = new QStackedWidget(this);
    stackWidget->addWidget(ltmPlot);
    stackWidget->addWidget(dataSummary);
    stackWidget->addWidget(plotArea);
    stackWidget->addWidget(compareplotArea);
    stackWidget->setCurrentIndex(0);
    mainLayout->addWidget(stackWidget);
    setChartLayout(mainLayout);

    // reveal controls
    QHBoxLayout *revealLayout = new QHBoxLayout;
    revealLayout->setContentsMargins(0,0,0,0);
    revealLayout->addStretch();
    revealLayout->addWidget(new QLabel(tr("Group by"),this));

    rGroupBy = new QxtStringSpinBox(this);
    QStringList strings;
    strings << tr("Days")
            << tr("Weeks")
            << tr("Months")
            << tr("Years")
            << tr("Time Of Day")
            << tr("All");
    rGroupBy->setStrings(strings);
    rGroupBy->setValue(0);

    revealLayout->addWidget(rGroupBy);
    rData = new QCheckBox(tr("Data Table"), this);
    rStack = new QCheckBox(tr("Stacked"), this);
    QVBoxLayout *checks = new QVBoxLayout;
    checks->setSpacing(2);
    checks->setContentsMargins(0,0,0,0);
    checks->addWidget(rData);
    checks->addWidget(rStack);
    revealLayout->addLayout(checks);
    revealLayout->addStretch();
    setRevealLayout(revealLayout);

    // add additional menu items before setting
    // controls since the menu is SET from setControls
    QAction *exportData = new QAction(tr("Export Chart Data..."), this);
    addAction(exportData);

    // the controls
    QWidget *c = new QWidget;
    c->setContentsMargins(0,0,0,0);
    QVBoxLayout *cl = new QVBoxLayout(c);
    cl->setContentsMargins(0,0,0,0);
    cl->setSpacing(0);
    setControls(c);

    // the popup
    popup = new GcPane();
    ltmPopup = new LTMPopup(context);
    QVBoxLayout *popupLayout = new QVBoxLayout();
    popupLayout->addWidget(ltmPopup);
    popup->setLayout(popupLayout);

    ltmTool = new LTMTool(context, &settings);

    // initialise
    settings.ltmTool = ltmTool;
    settings.data = NULL;
    settings.groupBy = LTM_DAY;
    settings.legend = ltmTool->showLegend->isChecked();
    settings.events = ltmTool->showEvents->isChecked();
    settings.shadeZones = ltmTool->shadeZones->isChecked();
    settings.showData = ltmTool->showData->isChecked();
    settings.stack = ltmTool->showStack->isChecked();
    settings.stackWidth = ltmTool->stackSlider->value();
    rData->setChecked(ltmTool->showData->isChecked());
    rStack->setChecked(ltmTool->showStack->isChecked());
    cl->addWidget(ltmTool);

    connect(this, SIGNAL(dateRangeChanged(DateRange)), this, SLOT(dateRangeChanged(DateRange)));
    connect(ltmTool, SIGNAL(filterChanged()), this, SLOT(filterChanged()));
    connect(context, SIGNAL(homeFilterChanged()), this, SLOT(filterChanged()));
    connect(ltmTool->groupBy, SIGNAL(currentIndexChanged(int)), this, SLOT(groupBySelected(int)));
    connect(rGroupBy, SIGNAL(valueChanged(int)), this, SLOT(rGroupBySelected(int)));
    connect(ltmTool->applyButton, SIGNAL(clicked(bool)), this, SLOT(applyClicked(void)));
    connect(ltmTool->shadeZones, SIGNAL(stateChanged(int)), this, SLOT(shadeZonesClicked(int)));
    connect(ltmTool->showData, SIGNAL(stateChanged(int)), this, SLOT(showDataClicked(int)));
    connect(rData, SIGNAL(stateChanged(int)), this, SLOT(showDataClicked(int)));
    connect(ltmTool->showStack, SIGNAL(stateChanged(int)), this, SLOT(showStackClicked(int)));
    connect(rStack, SIGNAL(stateChanged(int)), this, SLOT(showStackClicked(int)));
    connect(ltmTool->stackSlider, SIGNAL(valueChanged(int)), this, SLOT(zoomSliderChanged()));
    connect(ltmTool->showLegend, SIGNAL(stateChanged(int)), this, SLOT(showLegendClicked(int)));
    connect(ltmTool->showEvents, SIGNAL(stateChanged(int)), this, SLOT(showEventsClicked(int)));
    connect(ltmTool, SIGNAL(useCustomRange(DateRange)), this, SLOT(useCustomRange(DateRange)));
    connect(ltmTool, SIGNAL(useThruToday()), this, SLOT(useThruToday()));
    connect(ltmTool, SIGNAL(useStandardRange()), this, SLOT(useStandardRange()));
    connect(ltmTool, SIGNAL(curvesChanged()), this, SLOT(refresh()));
    connect(context, SIGNAL(filterChanged()), this, SLOT(refresh()));

    // comparing things
    connect(context, SIGNAL(compareDateRangesStateChanged(bool)), this, SLOT(compareChanged()));
    connect(context, SIGNAL(compareDateRangesChanged()), this, SLOT(compareChanged()));

    connect(context, SIGNAL(rideAdded(RideItem*)), this, SLOT(refresh(void)));
    connect(context, SIGNAL(rideDeleted(RideItem*)), this, SLOT(refresh(void)));
    connect(context, SIGNAL(configChanged()), this, SLOT(configChanged()));
    connect(context, SIGNAL(presetSelected(int)), this, SLOT(presetSelected(int)));

    // custom menu item
    connect(exportData, SIGNAL(triggered()), this, SLOT(exportData()));

    configChanged();
}
Ejemplo n.º 21
0
BitcoinGUI::BitcoinGUI(QWidget *parent) :
    QMainWindow(parent),
    clientModel(0),
    encryptWalletAction(0),
    changePassphraseAction(0),
    aboutQtAction(0),
    trayIcon(0),
    notificator(0),
    rpcConsole(0),
    prevBlocks(0)
{
    restoreWindowGeometry();
    setWindowTitle(tr("K-COIN") + " - " + tr("Wallet"));
#ifndef Q_OS_MAC
    QApplication::setWindowIcon(QIcon(":icons/bitcoin"));
    setWindowIcon(QIcon(":icons/bitcoin"));
#else
    setUnifiedTitleAndToolBarOnMac(true);
    QApplication::setAttribute(Qt::AA_DontShowIconsInMenus);
#endif
    // Create wallet frame and make it the central widget
    walletFrame = new WalletFrame(this);
    setCentralWidget(walletFrame);

    // Accept D&D of URIs
    setAcceptDrops(true);

    // Create actions for the toolbar, menu bar and tray/dock icon
    // Needs walletFrame to be initialized
    createActions();

    // Create application menu bar
    createMenuBar();

    // Create the toolbars
    createToolBars();

    // Create system tray icon and notification
    createTrayIcon();

    // Create status bar
    statusBar();

    // Status bar notification icons
    QFrame *frameBlocks = new QFrame();
    frameBlocks->setContentsMargins(0,0,0,0);
    frameBlocks->setMinimumWidth(56);
    frameBlocks->setMaximumWidth(56);
    QHBoxLayout *frameBlocksLayout = new QHBoxLayout(frameBlocks);
    frameBlocksLayout->setContentsMargins(3,0,3,0);
    frameBlocksLayout->setSpacing(3);
    labelEncryptionIcon = new QLabel();
    labelConnectionsIcon = new QLabel();
    labelBlocksIcon = new QLabel();
    frameBlocksLayout->addStretch();
    frameBlocksLayout->addWidget(labelEncryptionIcon);
    frameBlocksLayout->addStretch();
    frameBlocksLayout->addWidget(labelConnectionsIcon);
    frameBlocksLayout->addStretch();
    frameBlocksLayout->addWidget(labelBlocksIcon);
    frameBlocksLayout->addStretch();

    // Progress bar and label for blocks download
    progressBarLabel = new QLabel();
    progressBarLabel->setVisible(false);
    progressBar = new QProgressBar();
    progressBar->setAlignment(Qt::AlignCenter);
    progressBar->setVisible(false);

    // Override style sheet for progress bar for styles that have a segmented progress bar,
    // as they make the text unreadable (workaround for issue #1071)
    // See https://qt-project.org/doc/qt-4.8/gallery.html
    QString curStyle = QApplication::style()->metaObject()->className();
    if(curStyle == "QWindowsStyle" || curStyle == "QWindowsXPStyle")
    {
        progressBar->setStyleSheet("QProgressBar { background-color: #e8e8e8; border: 1px solid grey; border-radius: 7px; padding: 1px; text-align: center; } QProgressBar::chunk { background: QLinearGradient(x1: 0, y1: 0, x2: 1, y2: 0, stop: 0 #FF8000, stop: 1 orange); border-radius: 7px; margin: 0px; }");
    }

    statusBar()->addWidget(progressBarLabel);
    statusBar()->addWidget(progressBar);
    statusBar()->addPermanentWidget(frameBlocks);

    syncIconMovie = new QMovie(":/movies/update_spinner", "mng", this);

    rpcConsole = new RPCConsole(this);
    connect(openRPCConsoleAction, SIGNAL(triggered()), rpcConsole, SLOT(show()));

    // Install event filter to be able to catch status tip events (QEvent::StatusTip)
    this->installEventFilter(this);
}
Ejemplo n.º 22
0
MessageListWidget::MessageListWidget(QWidget *parent) :
    QWidget(parent), m_supportsFuzzySearch(false)
{
    tree = new MsgListView(this);

    m_quickSearchText = new LineEdit(this);
#if QT_VERSION >= 0x040700
    m_quickSearchText->setPlaceholderText(tr("Quick Search / Leading \":=\" for direct IMAP search"));
#endif
    m_queryPlaceholder = tr("<query>");

    connect(m_quickSearchText, SIGNAL(returnPressed()), this, SLOT(slotApplySearch()));
    connect(m_quickSearchText, SIGNAL(textChanged(QString)), this, SLOT(slotConditionalSearchReset()));
    connect(m_quickSearchText, SIGNAL(cursorPositionChanged(int, int)), this, SLOT(slotUpdateSearchCursor()));

    m_searchOptions = new QToolButton(this);
    m_searchOptions->setAutoRaise(true);
    m_searchOptions->setPopupMode(QToolButton::InstantPopup);
    m_searchOptions->setText("*");
    m_searchOptions->setIcon(loadIcon(QLatin1String("imap-search-details")));
    QMenu *optionsMenu = new QMenu(m_searchOptions);
    m_searchFuzzy = optionsMenu->addAction(tr("Fuzzy Search"));
    m_searchFuzzy->setCheckable(true);
    optionsMenu->addSeparator();
    m_searchInSubject = optionsMenu->addAction(tr("Subject"));
    m_searchInSubject->setCheckable(true);
    m_searchInSubject->setChecked(true);
    m_searchInBody = optionsMenu->addAction(tr("Body"));
    m_searchInBody->setCheckable(true);
    m_searchInSenders = optionsMenu->addAction(tr("Senders"));
    m_searchInSenders->setCheckable(true);
    m_searchInSenders->setChecked(true);
    m_searchInRecipients = optionsMenu->addAction(tr("Recipients"));
    m_searchInRecipients->setCheckable(true);

    optionsMenu->addSeparator();

    QMenu *complexMenu = new QMenu(tr("Complex IMAP query"), optionsMenu);
    connect(complexMenu, SIGNAL(triggered(QAction*)), this, SLOT(slotComplexSearchInput(QAction*)));
    complexMenu->addAction(tr("Not ..."))->setData("NOT " + m_queryPlaceholder);
    complexMenu->addAction(tr("Either... or..."))->setData("OR " + m_queryPlaceholder + " " + m_queryPlaceholder);
    complexMenu->addSeparator();
    complexMenu->addAction(tr("From sender"))->setData("FROM " + m_queryPlaceholder);
    complexMenu->addAction(tr("To receiver"))->setData("TO " + m_queryPlaceholder);
    complexMenu->addSeparator();
    complexMenu->addAction(tr("About subject"))->setData("SUBJECT " + m_queryPlaceholder);
    complexMenu->addAction(tr("Message contains ..."))->setData("BODY " + m_queryPlaceholder);
    complexMenu->addSeparator();
    complexMenu->addAction(tr("Before date"))->setData("BEFORE <d-mmm-yyyy>");
    complexMenu->addAction(tr("Since date"))->setData("SINCE <d-mmm-yyyy>");
    complexMenu->addSeparator();
    complexMenu->addAction(tr("Has been seen"))->setData("SEEN");

    optionsMenu->addMenu(complexMenu);

    m_searchOptions->setMenu(optionsMenu);
    connect (optionsMenu, SIGNAL(aboutToShow()), SLOT(slotDeActivateSimpleSearch()));

    delete m_quickSearchText->layout();
    QHBoxLayout *hlayout = new QHBoxLayout(m_quickSearchText);
    hlayout->setContentsMargins(0, 0, 0, 0);
    hlayout->addWidget(m_searchOptions);
    hlayout->addStretch();
    hlayout->addWidget(m_quickSearchText->clearButton());
    hlayout->activate(); // this processes the layout and ensures the toolbutton has it's final dimensions
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
    if (QGuiApplication::isLeftToRight())
#else
    if (qApp->keyboardInputDirection() == Qt::LeftToRight)
#endif
        m_quickSearchText->setTextMargins(m_searchOptions->width(), 0, 0, 0);
    else // ppl. in N Africa and the middle east write the wrong direction...
        m_quickSearchText->setTextMargins(0, 0, m_searchOptions->width(), 0);
    m_searchOptions->setCursor(Qt::ArrowCursor); // inherits I-Beam from lineedit otherwise

    QVBoxLayout *layout = new QVBoxLayout(this);
    layout->setSpacing(0);
    layout->addWidget(m_quickSearchText);
    layout->addWidget(tree);

    m_searchResetTimer = new QTimer(this);
    m_searchResetTimer->setSingleShot(true);
    connect(m_searchResetTimer, SIGNAL(timeout()), SLOT(slotApplySearch()));

    slotAutoEnableDisableSearch();
}
//FIXME: keep loaded plugins in own plugin manager and
//unload plugins to let load new version without
//the need to restart the application
void RackWindow::loadPlugin(QWidget *pluginHost)
{
    QDir pluginsDir(qApp->applicationDirPath());
#if defined(Q_OS_WIN)
    if (pluginsDir.dirName().toLower() == "debug" || pluginsDir.dirName().toLower() == "release")
        pluginsDir.cdUp();
#elif defined(Q_OS_MAC)
    if (pluginsDir.dirName() == "MacOS") {
        pluginsDir.cdUp();
        pluginsDir.cdUp();
        pluginsDir.cdUp();
    }
#endif

    if (!pluginsDir.cd("plugins"))
    {
        QMessageBox::information(this, "Error", "No plugin folder found");
        return;
    }


    QStringList pluginList = pluginsDir.entryList(QDir::Files);


    RSelectPluginDialog pluginDialog(this);
    pluginDialog.pluginListWidget->addItems(pluginList);
    pluginDialog.pluginListWidget->setCurrentRow(0);
    if (pluginDialog.exec())
    {



//    bool ok;
//    int newPluginIndex = RSelectPluginDialog::getIndex(this, pluginList, &ok);
//    if (ok) {

        //QString fileName = pluginsDir.entryList(QDir::Files).at(newPluginIndex);

        QString fileName = pluginsDir.entryList(QDir::Files).at(pluginDialog.pluginListWidget->currentRow());

        QPluginLoader pluginLoader(pluginsDir.absoluteFilePath(fileName));
        QObject *plugin = pluginLoader.instance();


        ///test

//        QList<QPluginLoader *> loadedPlugins = findChildren<QPluginLoader *>();

//        QObject *plugin = 0;

//        for (int i = 0; i < loadedPlugins.size(); ++i) {
//            if (loadedPlugins.at(i)->fileName() == pluginsDir.absoluteFilePath(fileName)) {
//                plugin = loadedPlugins.at(i)->instance();
//                break;
//            }
//        }

//        if (!plugin) {
//            QPluginLoader *pluginLoader = new QPluginLoader(pluginsDir.absoluteFilePath(fileName), this);
//            plugin = pluginLoader->instance();
//        }


        //debug code
        qDebug() << "we have the following plugins loaded:";
        QList<QPluginLoader *> debugPlugins = findChildren<QPluginLoader *>();
        for (int i = 0; i < debugPlugins.size(); ++i) {
            qDebug() << debugPlugins.at(i)->fileName();
        }


        //////////


//        m_pluginLoader = new QPluginLoader(pluginsDir.absoluteFilePath(fileName), this);
//        QObject *plugin = m_pluginLoader->instance();

        /////////////////


        if (plugin)
        {
            IWidgetPlugin *widgetPlugin = qobject_cast<IWidgetPlugin *>(plugin);
            if (widgetPlugin)
            {
                QWidget *newWidget = widgetPlugin->createRWidget(m_coreImpl, this);

                //get pointers from pluginhost:
                QStackedWidget *pluginStack = pluginHost->findChild<QStackedWidget *>("rackPluginStack");
                QToolBar *pluginHostToolBar = pluginHost->findChild<QToolBar *>("rackPluginHostToolBar");
                QToolBar *pluginToolBar = pluginHost->property("pluginToolBar").value<QToolBar *>();
                QSignalMapper *sm = pluginHost->findChild<QSignalMapper *>("rackPluginSwitchMapper");
                QActionGroup *ag = pluginHostToolBar->findChild<QActionGroup *>();

                //add plugin widget to the widget stack:
                pluginStack->setCurrentIndex(pluginStack->addWidget(newWidget));

                //create action for the toolbars:
                QAction *act = new QAction(widgetPlugin->name(), ag);
                act->setCheckable(true);
                act->setChecked(true);
                //qt bugfix: set transparent dummy icon to move button text down or right
                act->setIcon(QIcon(":/images/transparent-icon.png"));

                //create button for pluginhost toolbar:
                QToolButton *tb = new QToolButton;
                tb->setObjectName(QLatin1String(newWidget->metaObject()->className()) + "ToolButton");
                tb->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
                tb->setFocusPolicy(Qt::NoFocus);
                tb->setDefaultAction(act);
                RPushButton *settingsButton = new RPushButton;
                settingsButton->setObjectName("rackPluginHostToolBarSettingsButton");
                RPushButton *deleteButton = new RPushButton;
                deleteButton->setObjectName("rackPluginHostToolBarDeleteButton");
                QHBoxLayout *hl = new QHBoxLayout(tb);
                hl->setSpacing(0);
                hl->setContentsMargins(0,0,1,0);
                hl->addStretch();
                hl->addWidget(settingsButton);
                hl->addWidget(deleteButton);
                pluginHostToolBar->addWidget(tb);

                //create button for plugin toolbar:
                QToolButton *tb1 = new QToolButton;
                tb1->setObjectName(QLatin1String(newWidget->metaObject()->className()) + "ToolButton");
                tb1->setToolButtonStyle(Qt::ToolButtonTextUnderIcon);
                tb1->setFocusPolicy(Qt::NoFocus);
                tb1->setDefaultAction(act);
                pluginToolBar->addWidget(tb1);

                //connect action trigger to PluginSwitchMapper;
                QObject::connect(act, SIGNAL(triggered()), sm, SLOT(map()));
                sm->setMapping(act, newWidget);

                //connect delete signal
                //remove act from actiongroup and delete it:
                QObject::connect(deleteButton, SIGNAL(clicked()), m_mapperClosePlugin, SLOT(map()));
                m_mapperClosePlugin->setMapping(deleteButton, act);
                QObject::connect(deleteButton, SIGNAL(clicked()), newWidget, SLOT(deleteLater()));
                QObject::connect(deleteButton, SIGNAL(clicked()), tb1, SLOT(deleteLater()));
                QObject::connect(deleteButton, SIGNAL(clicked()), tb, SLOT(deleteLater()));

                //connect settings signal
                //if (plugin has settings) ...
                //QObject::connect(settingsButton, SIGNAL(clicked()),

            }
        }
        else
        {
            QMessageBox::information(this, "Error", "Could not load the plugin");
            qDebug() << pluginLoader.errorString();

        }
    }
}
EditorToolBar::EditorToolBar(QWidget *parent)
    : QWidget(parent)
{
    QString skin = "default";

    m_comboFontFamily = new CWizToolComboBoxFont(this);
    connect(m_comboFontFamily, SIGNAL(activated(const QString&)),
            SLOT(on_comboFontFamily_indexChanged(const QString&)));

    QStringList listSize;
    listSize << "9px" << "10px" << "11px" << "12px" << "13px"<< "14px"
             << "18px" << "24px" << "36px" << "48px" << "64px" << "72px";
    m_comboFontSize = new CWizToolComboBox(this);
    m_comboFontSize->addItems(listSize);
    connect(m_comboFontSize, SIGNAL(activated(const QString&)),
            SLOT(on_comboFontSize_indexChanged(const QString&)));

    m_btnFormatMatch = new CWizToolButton(this);
    m_btnFormatMatch->setIcon(::WizLoadSkinIcon(skin, "actionFormatMatch"));
    m_btnFormatMatch->setToolTip(tr("FormatMatch"));
    connect(m_btnFormatMatch, SIGNAL(clicked()), SLOT(on_btnFormatMatch_clicked()));

    m_btnForeColor = new CWizToolButtonColor(this);
    m_btnForeColor->setIcon(::WizLoadSkinIcon(skin, "actionFormatForeColor"));
    m_btnForeColor->setToolTip(tr("ForeColor"));
    connect(m_btnForeColor, SIGNAL(clicked()), SLOT(on_BtnForeColor_clicked()));

    m_btnBackColor = new CWizToolButtonColor(this);
    m_btnBackColor->setIcon(::WizLoadSkinIcon(skin, "actionFormatBackColor"));
    m_btnBackColor->setToolTip(tr("BackColor"));
    connect(m_btnBackColor, SIGNAL(clicked()), SLOT(on_BtnBackColor_clicked()));

    m_btnBold = new CWizToolButton(this);
    m_btnBold->setIcon(::WizLoadSkinIcon(skin, "actionFormatBold"));
    m_btnBold->setToolTip(tr("Bold"));
    connect(m_btnBold, SIGNAL(clicked()), SLOT(on_btnBold_clicked()));

    m_btnItalic = new CWizToolButton(this);
    m_btnItalic->setIcon(::WizLoadSkinIcon(skin, "actionFormatItalic"));
    m_btnItalic->setToolTip(tr("Italic"));
    connect(m_btnItalic, SIGNAL(clicked()), SLOT(on_btnItalic_clicked()));

    m_btnUnderLine = new CWizToolButton(this);
    m_btnUnderLine->setIcon(::WizLoadSkinIcon(skin, "actionFormatUnderLine"));
    m_btnUnderLine->setToolTip(tr("UnderLine"));
    connect(m_btnUnderLine, SIGNAL(clicked()), SLOT(on_btnUnderLine_clicked()));

    m_btnStrikeThrough = new CWizToolButton(this);
    m_btnStrikeThrough->setIcon(::WizLoadSkinIcon(skin, "actionFormatStrikeThrough"));
    m_btnStrikeThrough->setToolTip(tr("StrikeThrough"));
    connect(m_btnStrikeThrough, SIGNAL(clicked()), SLOT(on_btnStrikeThrough_clicked()));

    m_btnJustifyLeft = new CWizToolButton(this);
    m_btnJustifyLeft->setIcon(::WizLoadSkinIcon(skin, "actionFormatJustifyLeft"));
    m_btnJustifyLeft->setToolTip(tr("JustifyLeft"));
    connect(m_btnJustifyLeft, SIGNAL(clicked()), SLOT(on_btnJustifyLeft_clicked()));

    m_btnJustifyCenter = new CWizToolButton(this);
    m_btnJustifyCenter->setIcon(::WizLoadSkinIcon(skin, "actionFormatJustifyCenter"));
    m_btnJustifyCenter->setToolTip(tr("JustifyCenter"));
    connect(m_btnJustifyCenter, SIGNAL(clicked()), SLOT(on_btnJustifyCenter_clicked()));

    m_btnJustifyRight = new CWizToolButton(this);
    m_btnJustifyRight->setIcon(::WizLoadSkinIcon(skin, "actionFormatJustifyRight"));
    m_btnJustifyRight->setToolTip(tr("JustifyRight"));
    connect(m_btnJustifyRight, SIGNAL(clicked()), SLOT(on_btnJustifyRight_clicked()));

    m_btnUnorderedList = new CWizToolButton(this);
    m_btnUnorderedList->setIcon(::WizLoadSkinIcon(skin, "actionFormatInsertUnorderedList"));
    m_btnUnorderedList->setToolTip(tr("UnorderedList"));
    connect(m_btnUnorderedList, SIGNAL(clicked()), SLOT(on_btnUnorderedList_clicked()));

    m_btnOrderedList = new CWizToolButton(this);
    m_btnOrderedList->setIcon(::WizLoadSkinIcon(skin, "actionFormatInsertOrderedList"));
    m_btnOrderedList->setToolTip(tr("OrderedList"));
    connect(m_btnOrderedList, SIGNAL(clicked()), SLOT(on_btnOrderedList_clicked()));

    m_btnTable = new CWizToolButton(this);
    m_btnTable->setCheckable(false);
    m_btnTable->setIcon(::WizLoadSkinIcon(skin, "actionFormatInsertTable"));
    m_btnTable->setToolTip(tr("InsertTable"));
    connect(m_btnTable, SIGNAL(clicked()), SLOT(on_btnTable_clicked()));

    m_btnHorizontal = new CWizToolButton(this);
    m_btnHorizontal->setCheckable(false);
    m_btnHorizontal->setIcon(::WizLoadSkinIcon(skin, "actionFormatInsertHorizontal"));
    m_btnHorizontal->setToolTip(tr("InsertHorizontal"));
    connect(m_btnHorizontal, SIGNAL(clicked()), SLOT(on_btnHorizontal_clicked()));

    m_btnCheckList = new CWizToolButton(this);
    m_btnCheckList->setCheckable(false);
    m_btnCheckList->setIcon(::WizLoadSkinIcon(skin, "actionFormatInsertCheckList"));
    m_btnCheckList->setToolTip(tr("InsertCheckList"));
    connect(m_btnCheckList, SIGNAL(clicked()), SLOT(on_btnCheckList_clicked()));

    m_btnInsertImage = new CWizToolButton(this);
    m_btnInsertImage->setCheckable(false);
    m_btnInsertImage->setIcon(::WizLoadSkinIcon(skin, "actionFormatInsertImage"));
    m_btnInsertImage->setToolTip(tr("InsertImage"));
    connect(m_btnInsertImage, SIGNAL(clicked()), SLOT(on_btnImage_clicked()));

    m_btnSearchReplace = new CWizToolButton(this);
    m_btnSearchReplace->setCheckable(false);
    m_btnSearchReplace->setIcon(::WizLoadSkinIcon(skin, "actionFormatSearchReplace"));
    m_btnSearchReplace->setToolTip(tr("Find & Replace"));
    connect(m_btnSearchReplace, SIGNAL(clicked()), SLOT(on_btnSearchReplace_clicked()));

    QHBoxLayout* layout = new QHBoxLayout();
    layout->setContentsMargins(3, 0, 3, 0);
    layout->setAlignment(Qt::AlignVCenter);
    layout->setSpacing(2);
    setLayout(layout);

    layout->addWidget(m_comboFontFamily);
    layout->addSpacing(6);
    layout->addWidget(m_comboFontSize);
    layout->addSpacing(12);
    layout->addWidget(m_btnFormatMatch);
    layout->addWidget(m_btnForeColor);
    layout->addWidget(m_btnBackColor);
    layout->addWidget(m_btnBold);
    layout->addWidget(m_btnItalic);
    layout->addWidget(m_btnUnderLine);
    layout->addWidget(m_btnStrikeThrough);
    layout->addSpacing(12);
    layout->addWidget(m_btnJustifyLeft);
    layout->addWidget(m_btnJustifyCenter);
    layout->addWidget(m_btnJustifyRight);
    layout->addSpacing(12);
    layout->addWidget(m_btnUnorderedList);
    layout->addWidget(m_btnOrderedList);
    layout->addSpacing(12);
    layout->addWidget(m_btnTable);
    layout->addWidget(m_btnHorizontal);
    layout->addWidget(m_btnCheckList);
    layout->addWidget(m_btnInsertImage);
    layout->addSpacing(12);
    layout->addWidget(m_btnSearchReplace);
    layout->addStretch();
}
Ejemplo n.º 25
0
VCMatrix::VCMatrix(QWidget *parent, Doc *doc)
    : VCWidget(parent, doc)
    , m_matrixID(Function::invalidId())
    , m_instantApply(true)
{
    /* Set the class name "VCLabel" as the object name as well */
    setObjectName(VCMatrix::staticMetaObject.className());
    setFrameStyle(KVCFrameStyleSunken);

    QHBoxLayout *hBox = new QHBoxLayout(this);
    hBox->setContentsMargins(3, 3, 3, 10);
    hBox->setSpacing(5);

    m_slider = new ClickAndGoSlider();
    m_slider->setStyleSheet(CNG_DEFAULT_STYLE);
    m_slider->setFixedWidth(32);
    m_slider->setRange(0, 255);
    m_slider->setPageStep(1);
    m_slider->setInvertedAppearance(false);
    hBox->addWidget(m_slider);

    connect(m_slider, SIGNAL(valueChanged(int)),
            this, SLOT(slotSliderMoved(int)));

    QVBoxLayout *vbox = new QVBoxLayout(this);

    m_startColorButton = new QToolButton(this);
    m_startColorButton->setFixedSize(48, 48);
    m_startColorButton->setIconSize(QSize(42, 42));

    QWidgetAction* scAction = new QWidgetAction(this);
    m_scCnGWidget = new ClickAndGoWidget();
    m_scCnGWidget->setType(ClickAndGoWidget::RGB, NULL);
    scAction->setDefaultWidget(m_scCnGWidget);
    QMenu *startColorMenu = new QMenu();
    startColorMenu->addAction(scAction);
    m_startColorButton->setMenu(startColorMenu);
    m_startColorButton->setPopupMode(QToolButton::InstantPopup);

    connect(m_scCnGWidget, SIGNAL(colorChanged(QRgb)),
            this, SLOT(slotStartColorChanged(QRgb)));

    m_endColorButton = new QToolButton(this);
    m_endColorButton->setFixedSize(48, 48);
    m_endColorButton->setIconSize(QSize(42, 42));

    QWidgetAction* ecAction = new QWidgetAction(this);
    m_ecCnGWidget = new ClickAndGoWidget();
    m_ecCnGWidget->setType(ClickAndGoWidget::RGB, NULL);
    ecAction->setDefaultWidget(m_ecCnGWidget);
    QMenu *endColorMenu = new QMenu();
    endColorMenu->addAction(ecAction);
    m_endColorButton->setMenu(endColorMenu);
    m_endColorButton->setPopupMode(QToolButton::InstantPopup);

    connect(m_ecCnGWidget, SIGNAL(colorChanged(QRgb)),
            this, SLOT(slotEndColorChanged(QRgb)));

    m_label = new QLabel(this);
    m_label->setAlignment(Qt::AlignCenter);
    m_label->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
    vbox->addWidget(m_label);

    QHBoxLayout *btnHbox = new QHBoxLayout(this);

    btnHbox->addWidget(m_startColorButton);
    btnHbox->addWidget(m_endColorButton);

    vbox->addLayout(btnHbox);

    m_presetCombo = new QComboBox(this);
    //m_presetCombo->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Expanding);
    m_presetCombo->addItems(RGBScript::scriptNames(m_doc));
    connect(m_presetCombo, SIGNAL(currentIndexChanged(QString)),
            this, SLOT(slotAnimationChanged(QString)));
    vbox->addWidget(m_presetCombo);

    hBox->addLayout(vbox);

    m_controlsLayout = new FlowLayout();
    vbox->addLayout(m_controlsLayout);

    setType(VCWidget::MatrixWidget);
    setCaption(QString());
    resize(QSize(160, 120));

    /* Update the slider according to current mode */
    slotModeChanged(mode());
}
Ejemplo n.º 26
0
WarehouseGroup::WarehouseGroup(QWidget *pParent, const char *pName) :
  QGroupBox(pParent)
{
  _selectedOnly = false;
  if (_x_preferences)
    if (_x_preferences->boolean("selectedSites"))
      _selectedOnly=true;
  
  if(pName)
    setObjectName(pName);

  _fixed = true;
  _selectedGroup = new QWidget(this);
  QButtonGroup * buttonGroup = new QButtonGroup(this);
  
  _all = new QRadioButton(tr("All Sites"), this);
  _all->setObjectName("_all");
  _site = new QLabel(tr("Site:"),this);
  _site->setObjectName("_site");
  _selected = new QRadioButton(tr("Selected:"), _selectedGroup);
  _selected->setObjectName("_selected");
	 
  if (!_selectedOnly)
  {
    _all->setChecked(TRUE);
    buttonGroup->addButton(_all);
    buttonGroup->addButton(_selected);
  }
  
  _warehouses = new WComboBox(_selectedGroup, "_warehouses");

  if(_selectedOnly)
  {
    QHBoxLayout *hLayout = new QHBoxLayout(_selectedGroup);
    hLayout->setContentsMargins(0, 0, 0, 0);
    hLayout->setSpacing(5);
    hLayout->addWidget(_site);
    hLayout->addWidget(_warehouses);
    hLayout->addStretch();
    _selectedGroup->setLayout(hLayout);
    
    QVBoxLayout *vLayout = new QVBoxLayout(this);
    vLayout->setContentsMargins(5, 5, 5, 5);
    vLayout->setSpacing(0);
    vLayout->addWidget(_selectedGroup);
    setLayout(vLayout);
    
    _all->hide();
    _selected->hide();
  }
  else
  {
    _site->hide();
    setFixedSize(false);
  }

  connect(_selected, SIGNAL(toggled(bool)), _warehouses, SLOT(setEnabled(bool)));
  connect(buttonGroup, SIGNAL(buttonClicked(int)), this, SIGNAL(updated()));
  connect(_warehouses, SIGNAL(newID(int)), this, SIGNAL(updated()));

  if (((_x_preferences) ? _x_preferences->value("PreferredWarehouse").toInt() : -1) != -1)
    _selected->setChecked(TRUE);

  setTabOrder(_all, _selected);
  setTabOrder(_selected, _warehouses);
  setTabOrder(_warehouses, _all);
  setFocusProxy(_all);
  
  if (_x_metrics)
  {
    if (!_x_metrics->boolean("MultiWhs"))
    {
      this->hide();
      setAll();
    }
  }
}
Ejemplo n.º 27
0
QWidget* RKObjectListViewSettings::filterWidget (QWidget *parent) {
	RK_TRACE (APP);

	if (filter_widget) return filter_widget;

	filter_widget = new QWidget (parent);

	QVBoxLayout *layout = new QVBoxLayout (filter_widget);
	layout->setContentsMargins (0, 0, 0, 0);
	QHBoxLayout* hlayout = new QHBoxLayout ();
	hlayout->setContentsMargins (0, 0, 0, 0);
	layout->addLayout (hlayout);

	sline = new RKDynamicSearchLine (filter_widget);
	filter_widget->setFocusProxy (sline);
	sline->setModelToFilter (this);
	RKCommonFunctions::setTips (sline->regexpTip (), sline);
	connect (sline, SIGNAL (searchChanged(QRegExp)), this, SLOT (filterSettingsChanged()));
	hlayout->addWidget (sline);
	QPushButton* expander = new QPushButton (filter_widget);
	expander->setIcon (RKStandardIcons::getIcon (RKStandardIcons::ActionConfigureGeneric));
	expander->setCheckable (true);
	hlayout->addWidget (expander);

	filter_widget_expansion = new QWidget (filter_widget);
	layout->addWidget (filter_widget_expansion);
	connect (expander, SIGNAL (toggled(bool)), filter_widget_expansion, SLOT (setShown(bool)));
	filter_widget_expansion->hide ();
	QVBoxLayout *elayout = new QVBoxLayout (filter_widget_expansion);
	elayout->setContentsMargins (0, 0, 0, 0);

	QGroupBox *box = new QGroupBox (i18nc ("Fields==columns in tree view", "Fields to search in"), filter_widget_expansion);
	elayout->addWidget (box);
	QVBoxLayout *boxvlayout = new QVBoxLayout (box);
	QHBoxLayout *boxhlayout = new QHBoxLayout ();
	boxvlayout->addLayout (boxhlayout);
	boxhlayout->setContentsMargins (0, 0, 0, 0);
	filter_on_name_box = new QCheckBox (i18n ("Name"));
	boxhlayout->addWidget (filter_on_name_box);
	filter_on_label_box = new QCheckBox (i18n ("Label"));
	boxhlayout->addWidget (filter_on_label_box);
	filter_on_class_box = new QCheckBox (i18n ("Class"));
	boxhlayout->addWidget (filter_on_class_box);

	filter_on_name_box->setChecked (filter_on_name);
	filter_on_label_box->setChecked (filter_on_label);
	filter_on_class_box->setChecked (filter_on_class);
	connect (filter_on_name_box, SIGNAL(clicked(bool)), this, SLOT (filterSettingsChanged()));
	connect (filter_on_label_box, SIGNAL(clicked(bool)), this, SLOT (filterSettingsChanged()));
	connect (filter_on_class_box, SIGNAL(clicked(bool)), this, SLOT (filterSettingsChanged()));

	depth_box = new QComboBox ();
	depth_box->addItem (i18n ("Top level objects, only"));
	depth_box->addItem (i18n ("Top level objects, and direct children"));
	RKCommonFunctions::setTips (i18n ("Depth of search in the object tree.<ul>"
	                                      "<li><i>%1</i> means looking for matches in objects that are on the search path, only (in <i>.GlobalEnv</i> or a loaded package)</li>"
	                                      "<li><i>%2</i> includes direct child objects. In this case, the list will show matching objects on the search path, <i>and</i> objects on the search path that hold matching child objects.</li>", depth_box->itemText (0), depth_box->itemText (1)), depth_box);
	boxvlayout->addWidget (depth_box);

	depth_box->setCurrentIndex (1);
	connect (depth_box, SIGNAL (currentIndexChanged(QString)), this, SLOT (filterSettingsChanged()));

	type_box = new QComboBox ();
	type_box->addItem (i18n ("Show all objects"));
	type_box->addItem (i18n ("Show functions, only"));
	type_box->addItem (i18n ("Show objects excluding functions"));
	RKCommonFunctions::setTips (i18n ("When looking for a particular function, you may want to exclude 'data' objects, and vice versa. This control allows you to limit the list to objects that are not (or do not contain) functions, or to those that are (or contain) functions."), type_box);
	boxvlayout->addWidget (type_box);

	if (hide_functions) type_box->setCurrentIndex (2);
	else if (hide_non_functions) type_box->setCurrentIndex (1);
	else type_box->setCurrentIndex (0);
	connect (type_box, SIGNAL (currentIndexChanged(QString)), this, SLOT (filterSettingsChanged()));

	QHBoxLayout *bottom_layout = new QHBoxLayout (filter_widget);
	layout->addLayout (bottom_layout);
	QCheckBox* hidden_objects_box = new QCheckBox (i18n ("Show Hidden Objects"));
	hidden_objects_box->setChecked (persistent_settings[ShowObjectsHidden]);
	connect (hidden_objects_box, SIGNAL (clicked(bool)), persistent_settings_actions[ShowObjectsHidden], SLOT (setChecked(bool)));
	connect (persistent_settings_actions[ShowObjectsHidden], SIGNAL (triggered(bool)), hidden_objects_box, SLOT (setChecked(bool)));
	bottom_layout->addWidget (hidden_objects_box);

	// KF5 TODO: In frameworks, there is a function KIconUtils::kIconAddOverlay(). We could use this to overlay "view-filter" and discard, then use that
	// in a tool button (with tooltip), in order to save space.
	reset_filters_button = new QPushButton (i18nc ("Width is limited, please opt for something that is not much longer than the English string. Simply 'Clear'/'Reset' should be good enough to understand the function.", "Reset filters"), filter_widget);
	connect (reset_filters_button, SIGNAL (clicked(bool)), this, SLOT(resetFilters()));
	RKCommonFunctions::setTips (i18n ("Discards the current object search filters"), reset_filters_button);
	reset_filters_button->hide ();
	bottom_layout->addWidget (reset_filters_button);

	return filter_widget;
}
Ejemplo n.º 28
0
BitcoinGUI::BitcoinGUI(QWidget *parent):
    QMainWindow(parent),
    clientModel(0),
    walletModel(0),
    encryptWalletAction(0),
    changePassphraseAction(0),
    aboutQtAction(0),
    trayIcon(0),
    notificator(0),
    rpcConsole(0)
{
    resize(850, 550);
    setWindowTitle(tr("ECCoin") + " - " + tr("Wallet"));
	qApp->setStyleSheet("QMainWindow { background:rgb(220,220,220);font-family:'Proxima Nova Rg'; }" //content
    "#toolbar2 { border:none;width:28px;background-color:qlineargradient(x1: 0, y1: 0, x2: 0.5, y2: 0.5,stop: 0 rgb(195,205,250), stop: 1 rgb(28,29,33)) }"
    "QMenu { background: rgb(115,115,115); color:white; padding-bottom:10px; } "
    "QMenu::item { color:white; background-color: transparent; } "
    "QMenu::item:selected { background-color:qlineargradient(x1: 0, y1: 0, x2: 0.5, y2: 0.5,stop: 0 rgb(195,205,250), stop: 1 rgb(28,29,33)); }"
    "QMenuBar { background-color:qlineargradient(x1: 0, y1: 0, x2: 0.5, y2: 0.5,stop: 0 rgb(195,205,250), stop: 1 rgb(28,29,33));  color:white; }"
    "QMenuBar::item { font-size:12px;padding-bottom:12px;padding-top:12px;padding-left:15px;padding-right:15px;color:white; background-color: transparent; }"
    "QMenuBar::item:selected { background-color:qlineargradient(x1: 0, y1: 0, x2: 0.5, y2: 0.5,stop: 0 rgb(35,35,35), stop: 1 rgb(0, 141, 210)); }"
    );


#ifndef Q_OS_MAC
    qApp->setWindowIcon(QIcon(":icons/bitcoin"));
    setWindowIcon(QIcon(":icons/bitcoin"));
#else
    setUnifiedTitleAndToolBarOnMac(true);
    QApplication::setAttribute(Qt::AA_DontShowIconsInMenus);
#endif
    // Accept D&D of URIs
    setAcceptDrops(true);

    // Create actions for the toolbar, menu bar and tray/dock icon
    createActions();

    // Create application menu bar
    createMenuBar();

    // Create the toolbars
    createToolBars2();

    // Create the tray icon (or setup the dock icon)
    createTrayIcon();

    // Create tabs
    overviewPage = new OverviewPage();

    transactionsPage = new QWidget(this);
    QVBoxLayout *vbox = new QVBoxLayout();
    transactionView = new TransactionView(this);
    vbox->addWidget(transactionView);
    transactionsPage->setLayout(vbox);

    addressBookPage = new AddressBookPage(AddressBookPage::ForEditing, AddressBookPage::SendingTab);

    receiveCoinsPage = new AddressBookPage(AddressBookPage::ForEditing, AddressBookPage::ReceivingTab);

    sendCoinsPage = new SendCoinsDialog(this);
	blockBrowser = new BlockBrowser();
    chatWindow = new ChatWindow(this);
    //tradingWindow = new TradingWindow();
    signVerifyMessageDialog = new SignVerifyMessageDialog(this);

    centralWidget = new QStackedWidget(this);
    centralWidget->addWidget(overviewPage);
    centralWidget->addWidget(transactionsPage);
    centralWidget->addWidget(addressBookPage);
    centralWidget->addWidget(receiveCoinsPage);
    centralWidget->addWidget(sendCoinsPage);
	centralWidget->addWidget(blockBrowser);
    // centralWidget->addWidget(tradingWindow);
    centralWidget->addWidget(chatWindow);
    setCentralWidget(centralWidget);

    // Create status bar
    statusBar();

    // Status bar notification icons
    QFrame *frameBlocks = new QFrame();
    frameBlocks->setContentsMargins(0,0,0,0);
    frameBlocks->setMinimumWidth(56);
    frameBlocks->setMaximumWidth(56);
    QHBoxLayout *frameBlocksLayout = new QHBoxLayout(frameBlocks);
    frameBlocksLayout->setContentsMargins(3,0,3,0);
    frameBlocksLayout->setSpacing(3);
    labelEncryptionIcon = new QLabel();
    labelConnectionsIcon = new QLabel();
    labelBlocksIcon = new QLabel();
    frameBlocksLayout->addStretch();
    frameBlocksLayout->addWidget(labelEncryptionIcon);
    frameBlocksLayout->addStretch();
    frameBlocksLayout->addWidget(labelConnectionsIcon);
    frameBlocksLayout->addStretch();
    frameBlocksLayout->addWidget(labelBlocksIcon);
    frameBlocksLayout->addStretch();

    // Progress bar and label for blocks download
    progressBarLabel = new QLabel();
    progressBarLabel->setVisible(false);
    progressBar = new QProgressBar();
    progressBar->setAlignment(Qt::AlignCenter);
    progressBar->setVisible(false);

    // Override style sheet for progress bar for styles that have a segmented progress bar,
    // as they make the text unreadable (workaround for issue #1071)
    // See https://qt-project.org/doc/qt-4.8/gallery.html
    QString curStyle = qApp->style()->metaObject()->className();
    if(curStyle == "QWindowsStyle" || curStyle == "QWindowsXPStyle")
    {
        progressBar->setStyleSheet("QProgressBar { background-color: #e8e8e8; border: 1px solid grey; border-radius: 7px; padding: 1px; text-align: center; } QProgressBar::chunk { background: QLinearGradient(x1: 0, y1: 0, x2: 1, y2: 0, stop: 0 #FF8000, stop: 1 orange); border-radius: 7px; margin: 0px; }");
    }

    statusBar()->addWidget(progressBarLabel);
    statusBar()->addWidget(progressBar);
    statusBar()->addPermanentWidget(frameBlocks);

    syncIconMovie = new QMovie(":/movies/update_spinner", "mng", this);
	// this->setStyleSheet("background-color: #ceffee;");

    // Clicking on a transaction on the overview page simply sends you to transaction history page
    connect(overviewPage, SIGNAL(transactionClicked(QModelIndex)), this, SLOT(gotoHistoryPage()));
    connect(overviewPage, SIGNAL(transactionClicked(QModelIndex)), transactionView, SLOT(focusTransaction(QModelIndex)));

    // Double-clicking on a transaction on the transaction history page shows details
    connect(transactionView, SIGNAL(doubleClicked(QModelIndex)), transactionView, SLOT(showDetails()));

    rpcConsole = new RPCConsole(this);
    connect(openRPCConsoleAction, SIGNAL(triggered()), rpcConsole, SLOT(show()));

    // Clicking on "Verify Message" in the address book sends you to the verify message tab
    connect(addressBookPage, SIGNAL(verifyMessage(QString)), this, SLOT(gotoVerifyMessageTab(QString)));
    // Clicking on "Sign Message" in the receive coins page sends you to the sign message tab
    connect(receiveCoinsPage, SIGNAL(signMessage(QString)), this, SLOT(gotoSignMessageTab(QString)));

    gotoOverviewPage();
}
Ejemplo n.º 29
0
BitcoinGUI::BitcoinGUI(const NetworkStyle *networkStyle, QWidget *parent) :
    QMainWindow(parent),
    clientModel(0),
    walletFrame(0),
    unitDisplayControl(0),
    labelEncryptionIcon(0),
    labelConnectionsIcon(0),
    labelBlocksIcon(0),
    progressBarLabel(0),
    progressBar(0),
    progressDialog(0),
    appMenuBar(0),
    overviewAction(0),
    historyAction(0),
    quitAction(0),
    sendCoinsAction(0),
    usedSendingAddressesAction(0),
    usedReceivingAddressesAction(0),
    signMessageAction(0),
    verifyMessageAction(0),
    aboutAction(0),
    receiveCoinsAction(0),
    optionsAction(0),
    toggleHideAction(0),
    encryptWalletAction(0),
    backupWalletAction(0),
    changePassphraseAction(0),
    aboutQtAction(0),
    openRPCConsoleAction(0),
    openAction(0),
    showHelpMessageAction(0),
    trayIcon(0),
    trayIconMenu(0),
    notificator(0),
    rpcConsole(0),
    prevBlocks(0),
    spinnerFrame(0)
{
    GUIUtil::restoreWindowGeometry("nWindow", QSize(850, 550), this);

    QString windowTitle = tr("Viacoin Core") + " - ";
#ifdef ENABLE_WALLET
    /* if compiled with wallet support, -disablewallet can still disable the wallet */
    enableWallet = !GetBoolArg("-disablewallet", false);
#else
    enableWallet = false;
#endif // ENABLE_WALLET
    if(enableWallet)
    {
        windowTitle += tr("Wallet");
    } else {
        windowTitle += tr("Node");
    }
    windowTitle += " " + networkStyle->getTitleAddText();
#ifndef Q_OS_MAC
    QApplication::setWindowIcon(networkStyle->getAppIcon());
    setWindowIcon(networkStyle->getAppIcon());
#else
    MacDockIconHandler::instance()->setIcon(networkStyle->getAppIcon());
#endif
    setWindowTitle(windowTitle);

#if defined(Q_OS_MAC) && QT_VERSION < 0x050000
    // This property is not implemented in Qt 5. Setting it has no effect.
    // A replacement API (QtMacUnifiedToolBar) is available in QtMacExtras.
    setUnifiedTitleAndToolBarOnMac(true);
#endif

    rpcConsole = new RPCConsole(enableWallet ? this : 0);
#ifdef ENABLE_WALLET
    if(enableWallet)
    {
        /** Create wallet frame and make it the central widget */
        walletFrame = new WalletFrame(this);
        setCentralWidget(walletFrame);
    } else
#endif // ENABLE_WALLET
    {
        /* When compiled without wallet or -disablewallet is provided,
         * the central widget is the rpc console.
         */
        setCentralWidget(rpcConsole);
    }

    // Accept D&D of URIs
    setAcceptDrops(true);

    // Create actions for the toolbar, menu bar and tray/dock icon
    // Needs walletFrame to be initialized
    createActions(networkStyle);

    // Create application menu bar
    createMenuBar();

    // Create the toolbars
    createToolBars();

    // Create system tray icon and notification
    createTrayIcon(networkStyle);

    // Create status bar
    statusBar();

    // Status bar notification icons
    QFrame *frameBlocks = new QFrame();
    frameBlocks->setContentsMargins(0,0,0,0);
    frameBlocks->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Preferred);
    QHBoxLayout *frameBlocksLayout = new QHBoxLayout(frameBlocks);
    frameBlocksLayout->setContentsMargins(3,0,3,0);
    frameBlocksLayout->setSpacing(3);
    unitDisplayControl = new UnitDisplayStatusBarControl();
    labelEncryptionIcon = new QLabel();
    labelConnectionsIcon = new QLabel();
    labelBlocksIcon = new QLabel();
    if(enableWallet)
    {
        frameBlocksLayout->addStretch();
        frameBlocksLayout->addWidget(unitDisplayControl);
        frameBlocksLayout->addStretch();
        frameBlocksLayout->addWidget(labelEncryptionIcon);
    }
    frameBlocksLayout->addStretch();
    frameBlocksLayout->addWidget(labelConnectionsIcon);
    frameBlocksLayout->addStretch();
    frameBlocksLayout->addWidget(labelBlocksIcon);
    frameBlocksLayout->addStretch();

    // Progress bar and label for blocks download
    progressBarLabel = new QLabel();
    progressBarLabel->setVisible(false);
    progressBar = new GUIUtil::ProgressBar();
    progressBar->setAlignment(Qt::AlignCenter);
    progressBar->setVisible(false);

    // Override style sheet for progress bar for styles that have a segmented progress bar,
    // as they make the text unreadable (workaround for issue #1071)
    // See https://qt-project.org/doc/qt-4.8/gallery.html
    QString curStyle = QApplication::style()->metaObject()->className();
    if(curStyle == "QWindowsStyle" || curStyle == "QWindowsXPStyle")
    {
        progressBar->setStyleSheet("QProgressBar { background-color: #e8e8e8; border: 1px solid grey; border-radius: 7px; padding: 1px; text-align: center; } QProgressBar::chunk { background: QLinearGradient(x1: 0, y1: 0, x2: 1, y2: 0, stop: 0 #FF8000, stop: 1 orange); border-radius: 7px; margin: 0px; }");
    }

    statusBar()->addWidget(progressBarLabel);
    statusBar()->addWidget(progressBar);
    statusBar()->addPermanentWidget(frameBlocks);

    connect(openRPCConsoleAction, SIGNAL(triggered()), rpcConsole, SLOT(show()));

    // prevents an open debug window from becoming stuck/unusable on client shutdown
    connect(quitAction, SIGNAL(triggered()), rpcConsole, SLOT(hide()));

    // Install event filter to be able to catch status tip events (QEvent::StatusTip)
    this->installEventFilter(this);

    // Initially wallet actions should be disabled
    setWalletActionsEnabled(false);

    // Subscribe to notifications from core
    subscribeToCoreSignals();
}
Ejemplo n.º 30
0
DasmWindow::DasmWindow(running_machine* machine, QWidget* parent) :
	WindowQt(machine, NULL)
{
	setWindowTitle("Debug: Disassembly View");

	if (parent != NULL)
	{
		QPoint parentPos = parent->pos();
		setGeometry(parentPos.x()+100, parentPos.y()+100, 800, 400);
	}

	//
	// The main frame and its input and log widgets
	//
	QFrame* mainWindowFrame = new QFrame(this);

	// The top frame & groupbox that contains the input widgets
	QFrame* topSubFrame = new QFrame(mainWindowFrame);

	// The input edit
	m_inputEdit = new QLineEdit(topSubFrame);
	connect(m_inputEdit, SIGNAL(returnPressed()), this, SLOT(expressionSubmitted()));

	// The cpu combo box
	m_cpuComboBox = new QComboBox(topSubFrame);
	m_cpuComboBox->setObjectName("cpu");
	m_cpuComboBox->setMinimumWidth(300);
	connect(m_cpuComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(cpuChanged(int)));

	// The main disasm window
	m_dasmView = new DebuggerView(DVT_DISASSEMBLY,
									m_machine,
									this);

	// Force a recompute of the disassembly region
	downcast<debug_view_disasm*>(m_dasmView->view())->set_expression("curpc");

	// Populate the combo box & set the proper cpu
	populateComboBox();
	//const debug_view_source *source = mem->views[0]->view->source_for_device(curcpu);
	//gtk_combo_box_set_active(zone_w, mem->views[0]->view->source_list().indexof(*source));
	//mem->views[0]->view->set_source(*source);


	// Layout
	QHBoxLayout* subLayout = new QHBoxLayout(topSubFrame);
	subLayout->addWidget(m_inputEdit);
	subLayout->addWidget(m_cpuComboBox);
	subLayout->setSpacing(3);
	subLayout->setContentsMargins(2,2,2,2);

	QVBoxLayout* vLayout = new QVBoxLayout(mainWindowFrame);
	vLayout->setSpacing(3);
	vLayout->setContentsMargins(2,2,2,2);
	vLayout->addWidget(topSubFrame);
	vLayout->addWidget(m_dasmView);

	setCentralWidget(mainWindowFrame);

	//
	// Menu bars
	//
	// Create two commands
	QAction* breakpointSetAct = new QAction("Toggle Breakpoint At Cursor", this);
	QAction* runToCursorAct = new QAction("Run To Cursor", this);
	breakpointSetAct->setShortcut(Qt::Key_F9);
	runToCursorAct->setShortcut(Qt::Key_F4);
	connect(breakpointSetAct, SIGNAL(triggered(bool)), this, SLOT(toggleBreakpointAtCursor(bool)));
	connect(runToCursorAct, SIGNAL(triggered(bool)), this, SLOT(runToCursor(bool)));

	// Right bar options
	QActionGroup* rightBarGroup = new QActionGroup(this);
	rightBarGroup->setObjectName("rightbargroup");
	QAction* rightActRaw = new QAction("Raw Opcodes", this);
	QAction* rightActEncrypted = new QAction("Encrypted Opcodes", this);
	QAction* rightActComments = new QAction("Comments", this);
	rightActRaw->setCheckable(true);
	rightActEncrypted->setCheckable(true);
	rightActComments->setCheckable(true);
	rightActRaw->setActionGroup(rightBarGroup);
	rightActEncrypted->setActionGroup(rightBarGroup);
	rightActComments->setActionGroup(rightBarGroup);
	rightActRaw->setShortcut(QKeySequence("Ctrl+R"));
	rightActEncrypted->setShortcut(QKeySequence("Ctrl+E"));
	rightActComments->setShortcut(QKeySequence("Ctrl+C"));
	rightActRaw->setChecked(true);
	connect(rightBarGroup, SIGNAL(triggered(QAction*)), this, SLOT(rightBarChanged(QAction*)));

	// Assemble the options menu
	QMenu* optionsMenu = menuBar()->addMenu("&Options");
	optionsMenu->addAction(breakpointSetAct);
	optionsMenu->addAction(runToCursorAct);
	optionsMenu->addSeparator();
	optionsMenu->addActions(rightBarGroup->actions());
}