Beispiel #1
0
RawEditorWidget::RawEditorWidget(QWidget * par)
: QWidget(par)
{
	setObjectName("raw_event_editor");
	QGridLayout * l = new QGridLayout(this);
	QSplitter * spl = new QSplitter(Qt::Horizontal,this);
	spl->setObjectName("raweditor_splitter");
	spl->setChildrenCollapsible(false);

	l->addWidget(spl,0,0);

	KviTalVBox * boxi = new KviTalVBox(spl);
	boxi->setMaximumWidth(200);
	m_pTreeWidget = new RawTreeWidget(boxi);



	m_pTreeWidget->setColumnCount(1);
	m_pTreeWidget->setHeaderLabel(__tr2qs_ctx("Raw Event","editor"));

//	m_pTreeWidget->setMultiSelection(false);
	m_pTreeWidget->setSelectionMode(QAbstractItemView::SingleSelection);
//	m_pTreeWidget->setShowSortIndicator(true);
	m_pTreeWidget->setRootIsDecorated(true);
	m_pContextPopup = new QMenu(this);
	m_pTreeWidget->setContextMenuPolicy(Qt::CustomContextMenu);
	connect(m_pTreeWidget,SIGNAL(currentItemChanged(QTreeWidgetItem *,QTreeWidgetItem *)),this,SLOT(currentItemChanged(QTreeWidgetItem *,QTreeWidgetItem *)));

	connect(m_pTreeWidget,SIGNAL(customContextMenuRequested(const QPoint &)),this,SLOT(customContextMenuRequested(const QPoint &)));

	QPushButton * pb = new QPushButton(__tr2qs_ctx("&Export All To...","editor"),boxi);
	connect(pb,SIGNAL(clicked()),this,SLOT(exportAllEvents()));

	KviTalVBox * box = new KviTalVBox(spl);
	m_pNameEditor = new QLineEdit(box);
	m_pNameEditor->setToolTip(__tr2qs_ctx("Edit the raw event handler name.","editor"));
	m_pEditor = KviScriptEditor::createInstance(box);

	m_bOneTimeSetupDone = false;
	m_pLastEditedItem = 0;
}
ChatPageWidget::ChatPageWidget(int friendId, QWidget* parent) :
    QWidget(parent), friendId(friendId)
{
    friendItem = new FriendItemWidget(this);
    display = new MessageDisplayWidget(this);

    input = new InputTextWidget(this);
    connect(input, &InputTextWidget::sendMessage, this, &ChatPageWidget::sendMessage);
    connect(input, &InputTextWidget::sendAction,  this, &ChatPageWidget::sendAction);

    // Create emoticon menu :)
    CustomHintWidget *inputPanel = new CustomHintWidget(this, QSize(10, 10));
    EmoticonMenu *menu = new EmoticonMenu(this);
    emoticonButton = new QToolButton(inputPanel);
    emoticonButton->setPopupMode(QToolButton::InstantPopup);
    emoticonButton->setIcon(QIcon(":/icons/emoticons/emotion_smile.png"));
    emoticonButton->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Preferred);
    emoticonButton->setMenu(menu);
    connect(menu, &EmoticonMenu::insertEmoticon, input, &InputTextWidget::insertHtml);

    QHBoxLayout *inputLayout = new QHBoxLayout(inputPanel);
    inputLayout->setContentsMargins(0,0,0,0);
    inputLayout->setSpacing(2);
    inputLayout->addWidget(input);
    inputLayout->addWidget(emoticonButton);

    QSplitter* splitter = new QSplitter(this);
    splitter->setOrientation(Qt::Vertical);
    splitter->setChildrenCollapsible(false);
    splitter->addWidget(display);
    splitter->addWidget(inputPanel);
    splitter->setStretchFactor(0, 3);

    QVBoxLayout* layout = new QVBoxLayout(this);
    layout->addWidget(friendItem);
    layout->addWidget(splitter);
    layout->setSpacing(2);
    layout->setContentsMargins(0, 0, 2, 3);
}
QDatabaseConnectionView::QDatabaseConnectionView(QWidget* parent)
		: QWidget(parent)
{
	QVBoxLayout* pMainLayout = new QVBoxLayout();
	setLayout(pMainLayout);

	// Splitter
	QSplitter *pSplitter = new QSplitter();
	pSplitter->setChildrenCollapsible(false);
	pMainLayout->addWidget(pSplitter);

	// Create left panel
	QWidget* pVertConnectionPanel = makeConnectionVerticalPanel(pSplitter);
	pVertConnectionPanel->setMaximumWidth(300);
	pSplitter->addWidget(pVertConnectionPanel);

	// Create left panel
	m_pTabsInConnection = new QMidClickClosableTabWidget(); //Used to create a tab widget in the opened connection tab
	m_pTabsInConnection->setTabsClosable(true);
	m_pTabsInConnection->setMovable(true);
	pSplitter->addWidget(m_pTabsInConnection);
}
Beispiel #4
0
MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent)
{
    setWindowTitle("MathML Browser");    

    QSplitter *splitter = new QSplitter(this);
    splitter->setChildrenCollapsible(false);

    m_file_browser = new FileBrowser("*.mml", splitter);

    QWidget *formula_widget = new QWidget(splitter);
    QVBoxLayout *layout = new QVBoxLayout;
    layout->setSpacing(2);
    layout->setMargin(2);
    m_mml_widget = new QtMmlWidget(formula_widget);
    layout->addWidget(m_mml_widget);
    m_mml_widget->setBackgroundRole(QPalette::Base);
    m_compare_image = new QLabel;
    layout->addWidget(m_compare_image);
    m_compare_image->setAlignment(Qt::AlignCenter);
    m_compare_image->setBackgroundRole(QPalette::Base);
   
    formula_widget->setLayout(layout);
    setCentralWidget(splitter);

    QToolBar *tool_bar = new QToolBar(this);
    tool_bar->addAction(QIcon(":/images/zoom_in.png"),
		    "Zoom in", this, SLOT(zoomIn()));
    tool_bar->addAction(QIcon(":/images/zoom_out.png"),
		    "Zoom out", this, SLOT(zoomOut()));
    tool_bar->addAction(QIcon(":/images/frames.png"),
		    "Toggle frames", this, SLOT(toggleDrawFrames()));
   
    addToolBar(tool_bar);
    connect(m_file_browser, SIGNAL(fileSelected(const QString &)), this, SLOT(openFile(const QString &)));
}
EventEditor::EventEditor(QWidget * par)
: QWidget(par)
{
	setObjectName("event_editor");

	QGridLayout * l = new QGridLayout(this);

	QSplitter * spl = new QSplitter(Qt::Horizontal,this);
	spl->setChildrenCollapsible(false);

	l->addWidget(spl,0,0);

	KviTalVBox * vbox = new KviTalVBox(spl);
	vbox->setSpacing(0);
	vbox->setMargin(0);

	m_pTreeWidget = new EventEditorTreeWidget(vbox);

	QPushButton * pb = new QPushButton(__tr2qs_ctx("&Export All To...","editor"),vbox);
	connect(pb,SIGNAL(clicked()),this,SLOT(exportAllEvents()));

	KviTalVBox * box = new KviTalVBox(spl);
	spl->setStretchFactor (0,20);
	spl->setStretchFactor (1,80);

	box->setSpacing(0);
	box->setMargin(0);

	m_pNameEditor = new QLineEdit(box);
	m_pNameEditor->setToolTip(__tr2qs_ctx("Edit the event handler name.","editor"));

	m_pEditor = KviScriptEditor::createInstance(box);
	m_pEditor->setFocus();
	m_bOneTimeSetupDone = false;
	m_pLastEditedItem = 0;
}
Beispiel #6
0
PopupEditorWidget::PopupEditorWidget(QWidget * par)
    : QWidget(par)
{
	m_bSaving = false;

	QGridLayout * l = new QGridLayout(this);
	QSplitter * spl = new QSplitter(Qt::Horizontal, this);
	spl->setObjectName("popupeditor_horizontal_splitter");
	spl->setChildrenCollapsible(false);
	l->addWidget(spl, 0, 0);

	KviTalVBox * box = new KviTalVBox(spl);

	m_pTreeWidget = new QTreeWidget(box);
	m_pTreeWidget->setHeaderLabel(__tr2qs_ctx("Popup", "editor"));
	m_pTreeWidget->setSelectionMode(QAbstractItemView::ExtendedSelection);
	m_pTreeWidget->header()->setSortIndicatorShown(true);

	QPushButton * pb = new QPushButton(__tr2qs_ctx("&Export All to...", "editor"), box);
	connect(pb, SIGNAL(clicked()), this, SLOT(exportAll()));
	QPushButton * gn = new QPushButton(__tr2qs_ctx("&Export Selected to...", "editor"), box);
	connect(gn, SIGNAL(clicked()), this, SLOT(exportSelected()));

	m_pEditor = new SinglePopupEditor(spl);

	m_bOneTimeSetupDone = false;
	m_pLastEditedItem = nullptr;

	m_pContextPopup = new QMenu(this);
	m_pEmptyContextPopup = new QMenu(this);

	spl->setStretchFactor(0, 20);
	spl->setStretchFactor(1, 80);

	currentItemChanged(nullptr, nullptr);
}
ChatPageWidget::ChatPageWidget(const QString& userId, QWidget* parent) :
    QWidget(parent), userId(userId)
{
    friendItem = new FriendItemWidget(this);

    display = new MessageDisplayWidget(this);

    input = new InputTextWidget(this);
    connect(input, &InputTextWidget::messageSent, this, &ChatPageWidget::messageSent);
    connect(input, &InputTextWidget::messageSent, this, &ChatPageWidget::onMessageSent);

    QSplitter* splitter = new QSplitter(this);
    splitter->setOrientation(Qt::Vertical);
    splitter->setChildrenCollapsible(false);
    splitter->addWidget(display);
    splitter->addWidget(input);
    splitter->setStretchFactor(1, 3);

    QVBoxLayout* layout = new QVBoxLayout(this);
    layout->addWidget(friendItem);
    layout->addWidget(splitter);
    layout->setSpacing(2);
    layout->setContentsMargins(0, 3, 2, 3);
}
Beispiel #8
0
CPUWidget::CPUWidget(QWidget* parent) : QWidget(parent), ui(new Ui::CPUWidget)
{
    ui->setupUi(this);
    setDefaultDisposition();

    mDisas = new CPUDisassembly(0);
    mSideBar = new CPUSideBar(mDisas);
    connect(mDisas, SIGNAL(tableOffsetChanged(int_t)), mSideBar, SLOT(changeTopmostAddress(int_t)));
    connect(mDisas, SIGNAL(viewableRows(int)), mSideBar, SLOT(setViewableRows(int)));
    connect(mDisas, SIGNAL(repainted()), mSideBar, SLOT(repaint()));
    connect(mDisas, SIGNAL(selectionChanged(int_t)), mSideBar, SLOT(setSelection(int_t)));
    connect(Bridge::getBridge(), SIGNAL(dbgStateChanged(DBGSTATE)), mSideBar, SLOT(debugStateChangedSlot(DBGSTATE)));
    connect(Bridge::getBridge(), SIGNAL(updateSideBar()), mSideBar, SLOT(repaint()));

    QSplitter* splitter = new QSplitter(this);
    splitter->addWidget(mSideBar);
    splitter->addWidget(mDisas);
    splitter->setChildrenCollapsible(false);
    splitter->setHandleWidth(1);

    ui->mTopLeftUpperFrameLayout->addWidget(splitter);

    mInfo = new CPUInfoBox();
    ui->mTopLeftLowerFrameLayout->addWidget(mInfo);
    int height = mInfo->getHeight();
    ui->mTopLeftLowerFrame->setMinimumHeight(height + 2);
    ui->mTopLeftLowerFrame->setMaximumHeight(height + 2);

    connect(mDisas, SIGNAL(selectionChanged(int_t)), mInfo, SLOT(disasmSelectionChanged(int_t)));

    mGeneralRegs = new RegistersView(0);
    mGeneralRegs->setFixedWidth(1000);
    mGeneralRegs->setFixedHeight(1400);
    mGeneralRegs->ShowFPU(true);

    QScrollArea* scrollArea = new QScrollArea;
    scrollArea->setWidget(mGeneralRegs);

    scrollArea->horizontalScrollBar()->setStyleSheet("QScrollBar:horizontal{border:1px solid grey;background:#f1f1f1;height:10px}QScrollBar::handle:horizontal{background:#aaa;min-width:20px;margin:1px}QScrollBar::add-line:horizontal,QScrollBar::sub-line:horizontal{width:0;height:0}");
    scrollArea->verticalScrollBar()->setStyleSheet("QScrollBar:vertical{border:1px solid grey;background:#f1f1f1;width:10px}QScrollBar::handle:vertical{background:#aaa;min-height:20px;margin:1px}QScrollBar::add-line:vertical,QScrollBar::sub-line:vertical{width:0;height:0}");

    QPushButton* button_changeview = new QPushButton("");

    mGeneralRegs->SetChangeButton(button_changeview);

    button_changeview->setStyleSheet("Text-align:left;padding: 4px;padding-left: 10px;");
    QFont font = QFont("Lucida Console");
    font.setStyleHint(QFont::Monospace);
    font.setPointSize(8);
    button_changeview->setFont(font);
    connect(button_changeview, SIGNAL(clicked()), mGeneralRegs, SLOT(onChangeFPUViewAction()));

    ui->mTopRightFrameLayout->addWidget(button_changeview);

    ui->mTopRightFrameLayout->addWidget(scrollArea);

    mDump = new CPUDump(mDisas, 0); //dump widget
    ui->mBotLeftFrameLayout->addWidget(mDump);

    mStack = new CPUStack(0); //stack widget
    ui->mBotRightFrameLayout->addWidget(mStack);
}
Beispiel #9
0
OptionsDialog::OptionsDialog(QWidget * par,const QString &szGroup,bool bModal)
    : QDialog(par)
{
    setObjectName("general_options_dialog");

    setWindowIcon(*(g_pIconManager->getSmallIcon(KviIconManager::KVIrc)));

    m_szGroup = szGroup;

    QString szDialogTitle;

    if(szGroup.isEmpty() || KviQString::equalCI(szGroup,"general"))
    {
        szDialogTitle = __tr2qs_ctx("General Preferences","options");
    } else if(KviQString::equalCI(szGroup,"theme"))
    {
        szDialogTitle = __tr2qs_ctx("Theme Preferences","options");
    } else {
        szDialogTitle = __tr2qs_ctx("KVIrc Preferences","options");
    }

    QString szDialog = __tr2qs_ctx("This dialog contains a set of KVIrc settings.<br> Use the icons " \
                                   "on the left to navigate through the option pages. The text box in the " \
                                   "bottom left corner is a small search engine. It will highlight the " \
                                   "pages that contain options related to the search term you have entered.","options");


    QString szInfoTips;
    szInfoTips = __tr2qs_ctx("Many settings have tooltips that can be shown by holding " \
                             "the cursor over their label for a few seconds.","options");

    QString szOkCancelButtons = __tr2qs_ctx("When you have finished, click \"<b>OK</b>\" to accept your changes " \
                                            "or \"<b>Cancel</b>\" to discard them. Clicking \"<b>Apply</b>\" will commit your " \
                                            "changes without closing the window.","options");

    QString szFrontText = QString(
                              "<table width=\"100%\" height=\"100%\" valign=\"top\" align=\"center\" cellpadding=\"4\">" \
                              "<tr>" \
                              "<td bgcolor=\"#303030\" valign=\"top\">" \
                              "<center><h1><font color=\"#FFFFFF\">%1</font></h1></center>" \
                              "</td>" \
                              "</tr>" \
                              "<tr>" \
                              "<td valign=\"bottom\">" \
                              "<p>" \
                              "%2" \
                              "</p>" \
                              "<br style=\"line-height:5px;\"/>" \
                              "<p>" \
                              "%3" \
                              "</p>" \
                              "<br style=\"line-height:5px;\"/>" \
                              "<p>" \
                              "%4" \
                              "</p>" \
                              "</td>" \
                              "</tr>" \
                              "</table>"
                          ).arg(szDialogTitle, szDialog, szInfoTips, szOkCancelButtons);

    QString szCaption = szDialogTitle + " - KVIrc";
    setWindowTitle(szCaption);

    QGridLayout * g1 = new QGridLayout(this);
    QSplitter * spl = new QSplitter(Qt::Horizontal,this);
    spl->setChildrenCollapsible(false);

    g1->addWidget(spl,0,0,1,5);

    KviTalVBox * vbox = new KviTalVBox(spl);
    vbox->setSpacing(2);
    vbox->setMargin(3);

    // Controlling list view
    m_pTreeWidget = new QTreeWidget(vbox);

    m_pTreeWidget->header()->hide();
    m_pTreeWidget->setRootIsDecorated(true);
    m_pTreeWidget->setSortingEnabled(false);
    m_pTreeWidget->setSizePolicy(QSizePolicy::MinimumExpanding,QSizePolicy::MinimumExpanding);
    m_pTreeWidget->setCurrentItem(NULL);

    connect(m_pTreeWidget,SIGNAL(currentItemChanged(QTreeWidgetItem*, QTreeWidgetItem *)),this,SLOT(treeWidgetItemSelectionChanged(QTreeWidgetItem *, QTreeWidgetItem *)));

    KviTalHBox * hbox = new KviTalHBox(vbox);
    hbox->setSpacing(2);
    hbox->setMargin(3);

    m_pSearchLineEdit = new QLineEdit(hbox);
    connect(m_pSearchLineEdit,SIGNAL(returnPressed()),this,SLOT(searchClicked()));
    m_pSearchButton = new QToolButton(hbox);
    m_pSearchButton->setIconSize(QSize(16,16));
    m_pSearchButton->setIcon(*(g_pIconManager->getSmallIcon(KviIconManager::Search)));
    connect(m_pSearchButton,SIGNAL(clicked()),this,SLOT(searchClicked()));
    connect(m_pSearchLineEdit,SIGNAL(textChanged(const QString &)),this,SLOT(searchLineEditTextChanged(const QString &)));

    QString szTip = __tr2qs_ctx("<p>This is the search tool for this options dialog.</p>" \
                                "<p>You can enter a search term either in your native " \
                                "language or in English and press the button on the right. " \
                                "The pages that contain some options related to the " \
                                "search term will be highlighted and you will be able " \
                                "to quickly find them.</p><p>Try \"nickname\" for example.</p>","options");
    KviTalToolTip::add(m_pSearchLineEdit,szTip);
    KviTalToolTip::add(m_pSearchButton,szTip);

    vbox = new KviTalVBox(spl);
    vbox->setSpacing(2);
    vbox->setMargin(3);

    m_pCategoryLabel = new QLabel("<b>&nbsp;</b>",vbox);
    m_pCategoryLabel->setObjectName("labgeneraloptions");

    QFrame * f = new QFrame(vbox);
    f->setFrameStyle(QFrame::HLine | QFrame::Sunken);

    // Widget stack
    m_pWidgetStack = new QStackedWidget(vbox);
    vbox->setStretchFactor(m_pWidgetStack,1);

    // First widget visible
    m_pFrontWidget = new OptionsDialogFrontWidget(m_pWidgetStack,szFrontText);
    m_pWidgetStack->addWidget(m_pFrontWidget);

    int idx = m_pWidgetStack->indexOf(m_pFrontWidget);
    m_pWidgetStack->widget(idx)->raise();

    //  Ok,Cancel,Help
    QPushButton * b = new QPushButton(__tr2qs_ctx("&OK","options"),this);
    b->setObjectName("btnok");
    KviTalToolTip::add(b,__tr2qs_ctx("Close this dialog, accepting all changes.","options"));
    connect(b,SIGNAL(clicked()),this,SLOT(okClicked()));
    //b->setMinimumWidth(whatIsThisWidth);
    b->setIcon(*(g_pIconManager->getSmallIcon(KviIconManager::Accept)));
    g1->addWidget(b,1,2);

    b = new QPushButton(__tr2qs_ctx("&Apply","options"),this);
    b->setObjectName("btnapply");
    KviTalToolTip::add(b,__tr2qs_ctx("Commit all changes immediately.","options"));
    connect(b,SIGNAL(clicked()),this,SLOT(applyClicked()));
    b->setIcon(*(g_pIconManager->getSmallIcon(KviIconManager::Accept)));
    g1->addWidget(b,1,3);

    b = new QPushButton(__tr2qs_ctx("Cancel","options"),this);
    b->setObjectName("btncancel");
    KviTalToolTip::add(b,__tr2qs_ctx("Close this dialog, discarding all changes.","options"));
    b->setDefault(true);
    //b->setMinimumWidth(whatIsThisWidth);
    connect(b,SIGNAL(clicked()),this,SLOT(cancelClicked()));
    b->setIcon(*(g_pIconManager->getSmallIcon(KviIconManager::Discard)));
    g1->addWidget(b,1,4);

    g1->setRowStretch(0,1);
    g1->setColumnStretch(1,1);


    fillTreeWidget(0,g_pOptionsInstanceManager->instanceEntryTree(),szGroup);

    if(!parent())
    {
        if(KVI_OPTION_RECT(KviOption_rectGeneralOptionsDialogGeometry).y() < 5)
            KVI_OPTION_RECT(KviOption_rectGeneralOptionsDialogGeometry).setY(5);

        //setGeometry(KVI_OPTION_RECT(KviOption_rectGeneralOptionsDialogGeometry));
        resize(KVI_OPTION_RECT(KviOption_rectGeneralOptionsDialogGeometry).width(),
               KVI_OPTION_RECT(KviOption_rectGeneralOptionsDialogGeometry).height());
        move(KVI_OPTION_RECT(KviOption_rectGeneralOptionsDialogGeometry).x(),
             KVI_OPTION_RECT(KviOption_rectGeneralOptionsDialogGeometry).y());
    }

    new QShortcut(Qt::Key_Escape,this,SLOT(close()));

    if(bModal)
        setWindowModality(par ? Qt::WindowModal : Qt::ApplicationModal);
}
MainWindow::MainWindow(QFrame *parent)
    : QFrame(parent),isLeftNaviVisuable(true)
{
    setWindowFlags(Qt::FramelessWindowHint);

    setMouseTracking(true);
    setAttribute(Qt::WA_Hover, true);
    QString fileName("/style/system.qss");
    QFile file(fileName);
    if (!file.open(QFile::ReadOnly)) {
      file.setFileName(":/style/system.qss");
      file.open(QFile::ReadOnly);
    }
    setStyleSheet(file.readAll());
    file.close();


    ptrHeaderBar = new HeaderBar(this);//创建标题栏
    ptrStatusBar = new StatusBar(this);//创建状态栏
    QString msg = "Ready";
    ptrStatusBar->setMessage(msg);

    lft = new LeftNavi(this);
    lft->setFrameStyle(QFrame::NoFrame);

    rgt = new QStackedWidget(this);
    rgt->setObjectName("rgt");
    rgt->setFrameStyle(QFrame::NoFrame);



    NetPlanView *tpview = new NetPlanView();
    rgt->addWidget(tpview);
    NetResView *resview = new NetResView();
    rgt->addWidget(resview);
    QSplitter *mainSplitter = new QSplitter(this);
    mainSplitter->setFrameStyle(QFrame::NoFrame);
    mainSplitter->setHandleWidth(1);
    mainSplitter->setStyleSheet(
                QString("QSplitter::handle {background: qlineargradient("
                        "x1: 0, y1: 0, x2: 0, y2: 1,"
                        "stop: 0 %1, stop: 0.07 %2);}").
                arg(qApp->palette().background().color().name()).
                arg(qApp->palette().color(QPalette::Dark).name()));

    mainSplitter->setChildrenCollapsible(false);

    mainSplitter->addWidget(lft);
    mainSplitter->addWidget(rgt);
    mainSplitter->setStretchFactor(20,80);
    createToolBarNull();
    QHBoxLayout *ptrHLayout = new QHBoxLayout();
    ptrHLayout->setMargin(0);
    ptrHLayout->setSpacing(0);
    ptrHLayout->addWidget(pushButtonNull_);
    ptrHLayout->addWidget(mainSplitter);

    QVBoxLayout *ptrVLayout = new QVBoxLayout();//创建布局
    ptrVLayout->addWidget(ptrHeaderBar);//将部件加入到布局中
    ptrVLayout->addLayout(ptrHLayout);
    ptrVLayout->addWidget(ptrStatusBar);
    ptrVLayout->setSpacing(0);  //设置间距与边缘空白
    ptrVLayout->setContentsMargins(VALUE_DIS,VALUE_DIS,VALUE_DIS,VALUE_DIS);
    setLayout(ptrVLayout);
    setMinimumWidth(800);
    setMinimumHeight(600);


     createActions();


    FramelessHelper *pHelper = new FramelessHelper(this);
    pHelper->activateOn(this);  //激活当前窗体
    pHelper->setBorderWidth(VALUE_DIS);
    pHelper->setTitleHeight(HEADER_H);  //设置窗体的标题栏高度
    pHelper->setWidgetMovable(true);  //设置窗体可移动
    pHelper->setWidgetResizable(true);  //设置窗体可缩放

    connect(ptrHeaderBar, SIGNAL(signal_menu(QPoint)), this, SLOT(showMenu(QPoint)));
    connect(ptrHeaderBar, SIGNAL(signal_maxrestore()), this, SLOT(showMaxRestore()));

     //lft->setDatabase(db.db());
}
Beispiel #11
0
MusicPage::MusicPage(QWidget *parent) : QWidget(parent)
{
    this->setAttribute(Qt::WA_TranslucentBackground, true);//设置透明:窗体标题栏不透明,背景透明

    QHBoxLayout *controlLayout = new QHBoxLayout;
    addButton = new QPushButton("添加");
    addButton->setFixedHeight(22);
    controlLayout->addWidget(addButton);
    controlLayout->setSpacing(1);
    controlLayout->setMargin(0);
    connect(addButton, SIGNAL(clicked(bool)), this, SIGNAL(addMusics()));

    QWidget *controlBar = new QWidget;
    controlBar->setStyleSheet("background:rgba(244,244,244,40%);");
    //controlBar->setAttribute(Qt::WA_TranslucentBackground, true);
    controlBar->setFixedHeight(22);
    controlBar->setLayout(controlLayout);

    QPushButton *addList = new QPushButton("+创建列表");
    addList->setStyleSheet("background:rgba(244,244,244,40%);");

    listList = new ListList;
    connect(addList, SIGNAL(clicked(bool)), listList, SLOT(wantToCreateList()));
    connect(listList, SIGNAL(tryToCreateList(QString)), this, SIGNAL(tryToCreateList(QString)));
    connect(this, SIGNAL(createList(QString)), listList, SLOT(createList(QString)));
    connect(this, SIGNAL(createList(QString)), this, SLOT(createList()));
    connect(listList, SIGNAL(changeList(int)), this, SLOT(changeMusicList(int)));
    connect(listList, SIGNAL(deleteList(QString)), this, SIGNAL(deleteList(QString)));
    connect(listList, SIGNAL(deleteList(int)), this, SLOT(deleteList(int)));

    QVBoxLayout *leftLayout = new QVBoxLayout;
    leftLayout->addWidget(addList);
    leftLayout->addWidget(listList);
    leftLayout->setSpacing(1);
    leftLayout->setMargin(0);

    QWidget *leftWidget = new QWidget;
    leftWidget->setLayout(leftLayout);
    //leftWidget->setFixedWidth(80);
    leftWidget->setMinimumWidth(80);
    leftWidget->setMaximumWidth(120);

    musicLists = new QStackedWidget;
    musicLists->setMinimumWidth(80);
    musicLists->setMaximumWidth(420);

    QSplitter *splitter = new QSplitter(Qt::Horizontal, this);
    splitter->setOpaqueResize(true);
    splitter->setChildrenCollapsible(false);
    splitter->addWidget(leftWidget);
    splitter->addWidget(musicLists);
    splitter->setStretchFactor(0, 2);
    splitter->setStretchFactor(1, 5);
    splitter->setStyleSheet("QSplitter::handle { background-color: rgba(0,0,0,0%) }");
    splitter->setHandleWidth(1);
    QVBoxLayout *mainLayout = new QVBoxLayout;
    mainLayout->addWidget(controlBar);
    //mainLayout->addLayout(midLayout);
    mainLayout->addWidget(splitter);
    mainLayout->setSpacing(1);
    mainLayout->setMargin(1);

    this->setLayout(mainLayout);
}
PICWeeklySettings::PICWeeklySettings(QWidget *parent)
    : QWidget(parent)
{
    m_clientLabel = new QLabel(this);
    m_clientLabel->setText(tr("Client Code"));
    m_clientEdit = new QLineEdit(this);
    m_clientEdit->setObjectName("ClientEdit");
    m_clientEdit->setToolTip(tr("Code that appears on the top red band in the Bloomberg terminal in the BDS page."));

    m_portfolioLabel = new QLabel(this);
    m_portfolioLabel->setText(tr("Portfolio Code"));
    m_portfolioEdit = new QLineEdit(this);
    m_portfolioEdit->setObjectName("PortfolioEdit");
    m_portfolioEdit->setValidator(new QRegularExpressionValidator(QRegularExpression("\\d+"), this));
    m_portfolioEdit->setToolTip(tr("Code that appears in the PRTU page of the Bloomberg terminal in correspondence with the desired portfolio."));

    m_emailLabel = new QLabel(this);
    m_emailLabel->setText(tr("Destination Address"));
    m_emailEdit = new QLineEdit(this);
    m_emailEdit->setObjectName("EmailEdit");
    m_emailEdit->setValidator(new QRegularExpressionValidator(QRegularExpression("[A-Z0-9._%+-]+@[A-Z0-9.-]+\\.[A-Z]{2,4}(?:;[A-Z0-9._%+-]+@[A-Z0-9.-]+\\.[A-Z]{2,4})*", QRegularExpression::CaseInsensitiveOption | QRegularExpression::DontCaptureOption), this));

    m_emailccLabel = new QLabel(this);
    m_emailccLabel->setText(tr("CC Address"));
    m_emailccEdit = new QLineEdit(this);
    m_emailccEdit->setObjectName("EmailCCEdit");
    m_emailccEdit->setValidator(new QRegularExpressionValidator(QRegularExpression("[A-Z0-9._%+-]+@[A-Z0-9.-]+\\.[A-Z]{2,4}(?:;[A-Z0-9._%+-]+@[A-Z0-9.-]+\\.[A-Z]{2,4})*", QRegularExpression::CaseInsensitiveOption | QRegularExpression::DontCaptureOption), this));

    m_emailbccLabel = new QLabel(this);
    m_emailbccLabel->setText(tr("BCC Address"));
    m_emailbccEdit = new QLineEdit(this);
    m_emailbccEdit->setObjectName("EmailBCCEdit");
    m_emailbccEdit->setValidator(new QRegularExpressionValidator(QRegularExpression("[A-Z0-9._%+-]+@[A-Z0-9.-]+\\.[A-Z]{2,4}(?:;[A-Z0-9._%+-]+@[A-Z0-9.-]+\\.[A-Z]{2,4})*", QRegularExpression::CaseInsensitiveOption | QRegularExpression::DontCaptureOption), this));

    m_emailFromLabel = new QLabel(this);
    m_emailFromLabel->setText(tr("Sender Address"));
    m_emailFromEdit = new QLineEdit(this);
    m_emailFromEdit->setObjectName("FromEmailEdit");
    m_emailFromEdit->setValidator(new QRegularExpressionValidator(QRegularExpression("[A-Z0-9._%+-]+@[A-Z0-9.-]+\\.[A-Z]{2,4}(?:;[A-Z0-9._%+-]+@[A-Z0-9.-]+\\.[A-Z]{2,4})*", QRegularExpression::CaseInsensitiveOption | QRegularExpression::DontCaptureOption), this));

    m_emailServerLabel = new QLabel(this);
    m_emailServerLabel->setText(tr("Exchange Server"));
    m_emailServerEdit = new QLineEdit(this);
    m_emailServerEdit->setObjectName("ServerEdit");

    m_saveFolderLabel = new QLabel(this);
    m_saveFolderLabel->setText(tr("Save Emails In"));
    m_saveFolderEdit = new FolderEdit(this);
    m_saveFolderEdit->setObjectName("SaveFolder");

    m_addShockButton = new QPushButton(this);
    m_addShockButton->setToolTip(tr("Add Shock"));
    m_addShockButton->setIcon(QIcon::fromTheme("list-add", QIcon(":/icons/list-add.png")));
    m_addShockButton->setEnabled(false);
    m_removeShockButton = new QPushButton(this);
    m_removeShockButton->setToolTip(tr("Remove Shock"));
    m_removeShockButton->setEnabled(false);
    m_removeShockButton->setIcon(QIcon::fromTheme("list-remove", QIcon(":/icons/list-remove.png")));
    m_addScenarioButton = new QPushButton(this);
    m_addScenarioButton->setToolTip(tr("Add Scenario"));
    m_addScenarioButton->setIcon(QIcon::fromTheme("list-add", QIcon(":/icons/list-add.png")));
    m_removeScenarioButton = new QPushButton(this);
    m_removeScenarioButton->setToolTip(tr("Remove Scenario"));
    m_removeScenarioButton->setEnabled(false);
    m_removeScenarioButton->setIcon(QIcon::fromTheme("list-remove", QIcon(":/icons/list-remove.png")));
    m_copyScenarioButton = new QPushButton(this);
    m_copyScenarioButton->setToolTip(tr("Copy Scenario"));
    m_copyScenarioButton->setEnabled(false);
    m_copyScenarioButton->setIcon(QIcon::fromTheme("edit-copy", QIcon(":/icons/edit-copy.png")));
    m_moveUpScenButton = new QPushButton(this);
    m_moveUpScenButton->setToolTip(tr("Move scenario up"));
    m_moveUpScenButton->setEnabled(false);
    m_moveUpScenButton->setIcon(QIcon::fromTheme("arrow-up", QIcon(":/icons/arrow-up.png")));
    m_moveDownScenButton = new QPushButton(this);
    m_moveDownScenButton->setToolTip(tr("Move scenario down"));
    m_moveDownScenButton->setEnabled(false);
    m_moveDownScenButton->setIcon(QIcon::fromTheme("arrow-down", QIcon(":/icons/arrow-down.png")));

    m_ShocksModel = new QStandardItemModel(this);
    m_ShocksModel->setObjectName("ShocksModel");
    m_ShocksModel->setColumnCount(numRatingBands+2);
    m_ShocksModel->setHeaderData(0, Qt::Horizontal, tr("Sector")); //Also Scenario Name
    m_ShocksModel->setHeaderData(1, Qt::Horizontal, tr("Geography")); //Also Scenario Type
    m_ShocksModel->setHeaderData(2, Qt::Horizontal, tr("AAA"));
    m_ShocksModel->setHeaderData(3, Qt::Horizontal, tr("AA"));
    m_ShocksModel->setHeaderData(4, Qt::Horizontal, tr("A"));
    m_ShocksModel->setHeaderData(5, Qt::Horizontal, tr("BBB"));
    m_ShocksModel->setHeaderData(6, Qt::Horizontal, tr("Other"));
    m_ShocksModel->setHeaderData(6, Qt::Horizontal, true,Qt::UserRole);

    sectorDelegate = new ComboBoxDelegate(this);
    sectorDelegate->addItem(tr("Any"),true);
    geographyDelegate = new ComboBoxDelegate(this);
    geographyDelegate->addItem(tr("Any"), true);
    shockJumpDelegate = new ComboBoxDelegate(this);
    shockJumpDelegate->addItem(tr("Shock"), true);
    shockJumpDelegate->addItem(tr("Jump"), false);
    ValidatedDelegate* bpsDelegate = new ValidatedDelegate(this);
    bpsDelegate->setValidator(new QRegularExpressionValidator(QRegularExpression("\\d+"),this));

    m_scenarioList = new QTableView(this);
    m_scenarioList->verticalHeader()->hide();
    m_scenarioList->horizontalHeader()->hide();
    m_scenarioList->setSelectionMode(QAbstractItemView::SelectionMode::SingleSelection);
    m_scenarioList->setSortingEnabled(false);
    m_scenarioList->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch);
    m_scenarioList->setItemDelegateForColumn(1, shockJumpDelegate);
    m_scenarioList->setModel(m_ShocksModel);
    for (int i = 2; i < m_ShocksModel->columnCount(); i++)
        m_scenarioList->hideColumn(i);

    m_Shockview = new QTableView(this);
    m_Shockview->verticalHeader()->hide();
    m_Shockview->setSelectionMode(QAbstractItemView::SelectionMode::SingleSelection);
    m_Shockview->setSortingEnabled(false);
    m_Shockview->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch);
    m_Shockview->setItemDelegateForColumn(0, sectorDelegate);
    m_Shockview->setItemDelegateForColumn(1, geographyDelegate);
    m_Shockview->setModel(m_ShocksModel);
    for (int i = 2; i < numRatingBands + 2; i++)
        m_Shockview->setItemDelegateForColumn(i,bpsDelegate);
    for (int i = 0; i < numRatingBands+2; i++)
        m_Shockview->hideColumn(i);

    QVBoxLayout* mainLay = new QVBoxLayout(this);
    QGridLayout* emailLay = new QGridLayout;
    emailLay->addWidget(m_emailLabel, 0, 0);
    emailLay->addWidget(m_emailEdit, 0, 1);
    emailLay->addWidget(m_emailccLabel, 1, 0);
    emailLay->addWidget(m_emailccEdit, 1, 1);
    emailLay->addWidget(m_emailbccLabel, 2, 0);
    emailLay->addWidget(m_emailbccEdit, 2, 1);
    emailLay->addWidget(m_emailFromLabel, 3, 0);
    emailLay->addWidget(m_emailFromEdit, 3, 1);
    emailLay->addWidget(m_emailServerLabel, 4, 0);
    emailLay->addWidget(m_emailServerEdit, 4, 1);
    emailLay->addWidget(m_clientLabel, 5, 0);
    emailLay->addWidget(m_clientEdit, 5, 1);
    emailLay->addWidget(m_portfolioLabel, 6, 0);
    emailLay->addWidget(m_portfolioEdit, 6, 1);
    emailLay->addWidget(m_saveFolderLabel, 7, 0);
    emailLay->addWidget(m_saveFolderEdit, 7, 1);
    QSplitter* shockSplit = new QSplitter(this);
    QWidget* LeftSplit = new QWidget(this);
    QWidget* RightSplit = new QWidget(this);
    QGridLayout* shocksLayRight = new QGridLayout(RightSplit);
    QGridLayout* shocksLayLeft = new QGridLayout(LeftSplit);
    shockSplit->addWidget(LeftSplit);
    shockSplit->addWidget(RightSplit);
    shockSplit->setStretchFactor(0, 1);
    shockSplit->setStretchFactor(1, 2);
    shockSplit->setChildrenCollapsible(false);
    shockSplit->setOrientation(Qt::Horizontal);
    shocksLayLeft->addWidget(m_scenarioList, 0, 1, 5, 3);
    shocksLayLeft->addItem(new QSpacerItem(2, 2, QSizePolicy::Preferred, QSizePolicy::Expanding), 0, 0);
    shocksLayLeft->addWidget(m_moveUpScenButton, 1, 0);
    shocksLayLeft->addItem(new QSpacerItem(2, 2, QSizePolicy::Preferred, QSizePolicy::Expanding), 2, 0);
    shocksLayLeft->addWidget(m_moveDownScenButton, 3, 0);
    shocksLayLeft->addItem(new QSpacerItem(2, 2, QSizePolicy::Preferred, QSizePolicy::Expanding), 4, 0);
    shocksLayLeft->addWidget(m_addScenarioButton, 5, 1);
    shocksLayLeft->addWidget(m_copyScenarioButton, 5, 2);
    shocksLayLeft->addWidget(m_removeScenarioButton, 5, 3);
    shocksLayRight->addWidget(m_Shockview, 0, 0, 1, 2);
    shocksLayRight->addWidget(m_addShockButton, 1, 0);
    shocksLayRight->addWidget(m_removeShockButton, 1, 1);
    mainLay->addLayout(emailLay);
    mainLay->addWidget(shockSplit);
    m_scenarioList->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Expanding);

    connect(m_scenarioList->selectionModel(), &QItemSelectionModel::currentChanged, [&](const QModelIndex& idx) ->void {
        const bool idxValid = idx.isValid();
        m_addShockButton->setEnabled(idxValid);
        for (int i = 0; i < numRatingBands+2;i++){
            idxValid ? m_Shockview->showColumn(i) : m_Shockview->hideColumn(i);
        }
        m_Shockview->setRootIndex(m_ShocksModel->index(idx.row(),0)); 
    });
    connect(m_addScenarioButton, &QPushButton::clicked, [this]()->void {
        m_ShocksModel->insertRow(m_ShocksModel->rowCount()); 
        m_ShocksModel->insertColumns(0, numRatingBands + 2, m_ShocksModel->index(m_ShocksModel->rowCount() - 1, 0));
        m_ShocksModel->setData(m_ShocksModel->index(m_ShocksModel->rowCount() - 1, 0), tr("Scenario %1").arg(m_ShocksModel->rowCount()));
        m_ShocksModel->setData(m_ShocksModel->index(m_ShocksModel->rowCount() - 1, 1), true, Qt::UserRole);
        m_ShocksModel->setData(m_ShocksModel->index(m_ShocksModel->rowCount() - 1, 1), shockJumpDelegate->textForData(true));
    });
    connect(m_removeScenarioButton, &QPushButton::clicked, [this]()->void {
        if (m_scenarioList->currentIndex().isValid())
            m_ShocksModel->removeRow(m_scenarioList->currentIndex().row());
    });
    connect(m_addShockButton, &QPushButton::clicked, this, &PICWeeklySettings::addShock);
    connect(m_copyScenarioButton, &QPushButton::clicked, this, &PICWeeklySettings::copyScenario);
    connect(m_removeShockButton, &QPushButton::clicked, [this]()->void {
        if (m_Shockview->currentIndex().isValid())
            m_ShocksModel->removeRow(m_Shockview->currentIndex().row(), m_Shockview->rootIndex());
    });
    connect(m_Shockview->selectionModel(), &QItemSelectionModel::currentChanged, [&](const QModelIndex& idx) ->void {m_removeShockButton->setEnabled(idx.isValid()); });
    connect(m_scenarioList->selectionModel(), &QItemSelectionModel::currentChanged, [&](const QModelIndex& idx) ->void {
        m_removeScenarioButton->setEnabled(idx.isValid());
        m_copyScenarioButton->setEnabled(idx.isValid());
        if(idx.isValid()){
            m_moveUpScenButton->setEnabled(idx.row() > 0);
            m_moveDownScenButton->setEnabled(idx.row() < (idx.model()->rowCount() - 1));
        }
        else{
            m_moveUpScenButton->setEnabled(false);
            m_moveDownScenButton->setEnabled(false);
        }
    });
    connect(m_moveUpScenButton, &QPushButton::clicked, [this]()->void {
        if (m_scenarioList->selectionModel()->currentIndex().isValid()) {
            const int currRow = m_scenarioList->selectionModel()->currentIndex().row();
            if (currRow > 0)
               moveModelRow(currRow, currRow - 1);
        }
    });
    connect(m_moveDownScenButton, &QPushButton::clicked, [this]()->void {
        if (m_scenarioList->selectionModel()->currentIndex().isValid()) {
            const int currRow = m_scenarioList->selectionModel()->currentIndex().row();
            if (currRow < (m_ShocksModel->rowCount()-1))
                moveModelRow(currRow, currRow + 1);
        }
    });
}
Beispiel #13
0
/*!
	\class LabelWidget
 	\brief Widget for editing the properties of a TextLabel object, mostly used in an appropriate dock widget.

	In order the properties of the label to be shown, \c loadConfig() has to be called with the correspondig KConfigGroup
	(settings for a label in *Plot, Axis etc. or for an independent label on the worksheet).

	\ingroup kdefrontend
 */
LabelWidget::LabelWidget(QWidget* parent) : QWidget(parent),
	m_label(0),
	m_initializing(false),
	m_dateTimeMenu(new QMenu(this)),
	m_teXEnabled(false) {

// see legacy/LabelWidget.cpp
	ui.setupUi(this);

	QSplitter* splitter = new QSplitter(Qt::Vertical, this);
	splitter->setHandleWidth(1);
	splitter->addWidget(ui.frameTop);
	splitter->addWidget(ui.frameBottom);
	splitter->setChildrenCollapsible(false);
	ui.lText->setMinimumWidth(ui.lGeometry->width());
	this->layout()->addWidget(splitter);

	m_dateTimeMenu->setSeparatorsCollapsible(false); //we don't want the first separator to be removed

	ui.kcbFontColor->setColor(Qt::black); // default color

	//Icons
	ui.tbFontBold->setIcon( QIcon::fromTheme("format-text-bold") );
	ui.tbFontItalic->setIcon( QIcon::fromTheme("format-text-italic") );
	ui.tbFontUnderline->setIcon( QIcon::fromTheme("format-text-underline") );
	ui.tbFontStrikeOut->setIcon( QIcon::fromTheme("format-text-strikethrough") );
	ui.tbFontSuperScript->setIcon( QIcon::fromTheme("format-text-superscript") );
	ui.tbFontSubScript->setIcon( QIcon::fromTheme("format-text-subscript") );
	ui.tbSymbols->setIcon( QIcon::fromTheme("labplot-format-text-symbol") );
	ui.tbDateTime->setIcon( QIcon::fromTheme("chronometer") );
	ui.tbTexUsed->setIcon( QIcon::fromTheme("labplot-TeX-logo") );

	//Positioning and alignment
	ui.cbPositionX->addItem(i18n("left"));
	ui.cbPositionX->addItem(i18n("center"));
	ui.cbPositionX->addItem(i18n("right"));
	ui.cbPositionX->addItem(i18n("custom"));

	ui.cbPositionY->addItem(i18n("top"));
	ui.cbPositionY->addItem(i18n("center"));
	ui.cbPositionY->addItem(i18n("bottom"));
	ui.cbPositionY->addItem(i18n("custom"));

	ui.cbHorizontalAlignment->addItem(i18n("left"));
	ui.cbHorizontalAlignment->addItem(i18n("center"));
	ui.cbHorizontalAlignment->addItem(i18n("right"));

	ui.cbVerticalAlignment->addItem(i18n("top"));
	ui.cbVerticalAlignment->addItem(i18n("center"));
	ui.cbVerticalAlignment->addItem(i18n("bottom"));

	//check whether the used latex compiler is available.
	//Following logic is implemented (s.a. LabelWidget::teXUsedChanged()):
	//1. in case latex was used to generate the text label in the stored project
	//and no latex is available on the target system, latex button is toggled and
	//the user still can switch to the non-latex mode.
	//2. in case the label was in the non-latex mode and no latex is available,
	//deactivate the latex button so the user cannot switch to this mode.
	m_teXEnabled = TeXRenderer::enabled();

#ifdef HAVE_KF5_SYNTAX_HIGHLIGHTING
	m_highlighter = new KSyntaxHighlighting::SyntaxHighlighter(ui.teLabel->document());
	m_highlighter->setDefinition(m_repository.definitionForName("LaTeX"));
#endif

	//SLOTS
	// text properties
	connect(ui.tbTexUsed, SIGNAL(clicked(bool)), this, SLOT(teXUsedChanged(bool)) );
	connect(ui.teLabel, SIGNAL(textChanged()), this, SLOT(textChanged()));
	connect(ui.teLabel, SIGNAL(currentCharFormatChanged(QTextCharFormat)),
	        this, SLOT(charFormatChanged(QTextCharFormat)));
	connect(ui.kcbFontColor, SIGNAL(changed(QColor)), this, SLOT(fontColorChanged(QColor)));
	connect(ui.tbFontBold, SIGNAL(clicked(bool)), this, SLOT(fontBoldChanged(bool)));
	connect(ui.tbFontItalic, SIGNAL(clicked(bool)), this, SLOT(fontItalicChanged(bool)));
	connect(ui.tbFontUnderline, SIGNAL(clicked(bool)), this, SLOT(fontUnderlineChanged(bool)));
	connect(ui.tbFontStrikeOut, SIGNAL(clicked(bool)), this, SLOT(fontStrikeOutChanged(bool)));
	connect(ui.tbFontSuperScript, SIGNAL(clicked(bool)), this, SLOT(fontSuperScriptChanged(bool)));
	connect(ui.tbFontSubScript, SIGNAL(clicked(bool)), this, SLOT(fontSubScriptChanged(bool)));
	connect(ui.tbSymbols, SIGNAL(clicked(bool)), this, SLOT(charMenu()));
	connect(ui.tbDateTime, SIGNAL(clicked(bool)), this, SLOT(dateTimeMenu()));
	connect(m_dateTimeMenu, SIGNAL(triggered(QAction*)), this, SLOT(insertDateTime(QAction*)) );
	connect(ui.kfontRequester, SIGNAL(fontSelected(QFont)), this, SLOT(fontChanged(QFont)));
	connect(ui.kfontRequesterTeX, SIGNAL(fontSelected(QFont)), this, SLOT(teXFontChanged(QFont)));
	connect(ui.sbFontSize, SIGNAL(valueChanged(int)), this, SLOT(fontSizeChanged(int)) );

	// geometry
	connect( ui.cbPositionX, SIGNAL(currentIndexChanged(int)), this, SLOT(positionXChanged(int)) );
	connect( ui.cbPositionY, SIGNAL(currentIndexChanged(int)), this, SLOT(positionYChanged(int)) );
	connect( ui.sbPositionX, SIGNAL(valueChanged(double)), this, SLOT(customPositionXChanged(double)) );
	connect( ui.sbPositionY, SIGNAL(valueChanged(double)), this, SLOT(customPositionYChanged(double)) );
	connect( ui.cbHorizontalAlignment, SIGNAL(currentIndexChanged(int)), this, SLOT(horizontalAlignmentChanged(int)) );
	connect( ui.cbVerticalAlignment, SIGNAL(currentIndexChanged(int)), this, SLOT(verticalAlignmentChanged(int)) );
	connect( ui.sbRotation, SIGNAL(valueChanged(int)), this, SLOT(rotationChanged(int)) );
	connect( ui.sbOffsetX, SIGNAL(valueChanged(double)), this, SLOT(offsetXChanged(double)) );
	connect( ui.sbOffsetY, SIGNAL(valueChanged(double)), this, SLOT(offsetYChanged(double)) );

	connect( ui.chbVisible, SIGNAL(clicked(bool)), this, SLOT(visibilityChanged(bool)) );

	//TODO: https://bugreports.qt.io/browse/QTBUG-25420
	ui.tbFontUnderline->hide();
	ui.tbFontStrikeOut->hide();
}
Beispiel #14
0
SyntaxEditorWindow::SyntaxEditorWindow(const QSharedPointer<SyntaxList> &syntaxList, const QString &syntaxName,
		const QString &category, const QString &syntaxHint, QWidget *parent) :
		QWidget(parent), syntaxList(syntaxList), syntaxName(syntaxName)
{
	setWindowRole("kadu-syntax-editor");

	setWindowTitle(tr("Kadu syntax editor"));
	setAttribute(Qt::WA_DeleteOnClose);

	QVBoxLayout *layout = new QVBoxLayout(this);

	QSplitter *splitter = new QSplitter(this);
	layout->addWidget(splitter);
	splitter->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
	splitter->setChildrenCollapsible(false);

	QWidget *splitterleft = new QWidget(splitter);
	QVBoxLayout *splitterleftlayout = new QVBoxLayout(splitterleft);
	splitterleftlayout->setMargin(0);
	splitterleftlayout->setSpacing(5);

	editor = new QTextEdit(this);
	splitterleftlayout->addWidget(editor);
	editor->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
	editor->setAcceptRichText(true);
	editor->setPlainText(syntaxList->readSyntax(syntaxName));
	QFont font = this->font();
	font.setFamily("monospace");
	if(font.pixelSize() == -1)
		font.setPointSizeF(font.pointSizeF() - 0.5);
	else
		font.setPixelSize(font.pixelSize() - 2);
	editor->setFont(font);
	editor->setMinimumSize(EDITOR_MINIMUM_SIZE);

	if (!syntaxHint.isEmpty())
	{
		QLabel *editorhint = new QLabel(this);
		splitterleftlayout->addWidget(editorhint);
		editorhint->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Minimum);
		editorhint->setWordWrap(true);
		editorhint->setText(syntaxHint);
	}

	QWidget *splitterright = new QWidget(splitter);
	QVBoxLayout *splitterrightlayout = new QVBoxLayout(splitterright);
	splitterrightlayout->setMargin(0);
	splitterrightlayout->setSpacing(5);

	previewPanel = new Preview(this);
	splitterrightlayout->addWidget(previewPanel);
	previewPanel->setMinimumHeight(0);
	previewPanel->setMaximumHeight(QWIDGETSIZE_MAX);
	previewPanel->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Expanding);
	previewPanel->setResetBackgroundColor(config_file.readEntry("Look", category + "BgColor"));
	previewPanel->setMinimumSize(PREVIEW_MINIMUM_SIZE);

	QPushButton *previewbutton = new QPushButton(qApp->style()->standardIcon(QStyle::SP_BrowserReload), tr("Refresh Preview"), this);
	splitterrightlayout->addWidget(previewbutton);
	connect(previewbutton, SIGNAL(clicked()), this, SLOT(refreshPreview()));

	QDialogButtonBox *buttonslayout = new QDialogButtonBox(Qt::Horizontal, this);
	layout->addWidget(buttonslayout);
	QPushButton *saveSyntax = new QPushButton(qApp->style()->standardIcon(QStyle::SP_DialogOkButton), tr("Save"), this);
	QPushButton *saveAsSyntax = new QPushButton(qApp->style()->standardIcon(QStyle::SP_DialogSaveButton), tr("Save as..."), this);
	QPushButton *cancel = new QPushButton(qApp->style()->standardIcon(QStyle::SP_DialogCancelButton), tr("Cancel"), this);
	buttonslayout->addButton(saveSyntax, QDialogButtonBox::YesRole);
	buttonslayout->addButton(saveAsSyntax, QDialogButtonBox::ActionRole);
	buttonslayout->addButton(cancel, QDialogButtonBox::RejectRole);

	splitter->setSizes( QList<int>() << splitter->sizeHint().width() << 1 );

	if (syntaxList->isGlobal(syntaxName))
		saveSyntax->setDisabled(true);
	else
		connect(saveSyntax, SIGNAL(clicked()), this, SLOT(save()));
	connect(saveAsSyntax, SIGNAL(clicked()), this, SLOT(saveAs()));
	connect(cancel, SIGNAL(clicked()), this, SLOT(close()));

	loadWindowGeometry(this, "Look", "SyntaxEditorGeometry", 0, 50, 790, 480);
}
Beispiel #15
0
MusicWindow::MusicWindow(QWidget *parent) : MainWindow(parent)
{
    this->setWindowIcon(QIcon(":/images/icons/app_icon"));

    systemTrayIcon = new MySystemTrayIcon(this);
    connect(systemTrayIcon, SIGNAL(showWindow()), this, SLOT(show()));
    connect(systemTrayIcon, SIGNAL(quit()), this, SLOT(close()));

    player = new MyPlayer();
    connect(player, SIGNAL(playerStateChanged(int)), this, SLOT(playerStateChanged(int)));
    connect(player, SIGNAL(musicChanged(QString,int)), this, SLOT(musicChanged(QString,int)));

    topBar = new TopBar(this);
    connect(topBar, SIGNAL(setMinSize()), this, SLOT(showMinimized()));
    connect(topBar, SIGNAL(setMaxSize()), this, SLOT(setMaxSize()));
    connect(topBar, SIGNAL(closeWindow()), this, SLOT(hide()));
    connect(topBar, SIGNAL(quit()), this, SLOT(close()));
    connect(topBar, SIGNAL(setBackgroud(QString)), this, SLOT(setBackgroud(QString)));
    connect(topBar, SIGNAL(aboutQtMusic()), this, SLOT(aboutQtMusic()));

    fuctionPage = new QStackedWidget;
    fuctionPage->setMinimumWidth(200);

    lyricLabel = new LyricLabel(false, this);
    connect(player, SIGNAL(positionChanged(qint64)), lyricLabel, SLOT(postionChanged(qint64)));
    connect(lyricLabel, SIGNAL(changeTo(qint64)), player, SLOT(setPosition(qint64)));

    networkPage = new NetworkPage();

    QLabel *label2 = new QLabel("Network");
    label2->setAlignment(Qt::AlignCenter);
    QLabel *label3 = new QLabel("Download");
    label3->setAlignment(Qt::AlignCenter);
    fuctionPage->addWidget(lyricLabel);
    fuctionPage->addWidget(networkPage);
    fuctionPage->addWidget(label3);
    fuctionPage->setCurrentIndex(0);
    connect(topBar, SIGNAL(selectFuction(int)), fuctionPage, SLOT(setCurrentIndex(int)));

    musicPage = new MusicPage;
    musicPage->setMaximumWidth(500);
    musicPage->setMinimumWidth(300);
    connect(musicPage, SIGNAL(tryToCreateList(QString)), this, SLOT(tryToCreateList(QString)));
    connect(musicPage, SIGNAL(deleteList(QString)), this, SLOT(deleteList(QString)));
    connect(musicPage, SIGNAL(addMusics()), this, SLOT(addMusics()));
    connect(musicPage, SIGNAL(play(QString,int)), player, SLOT(playTheMusic(QString,int)));
    connect(musicPage, SIGNAL(removeTheMusic(QString,int)), this, SLOT(removeTheMusic(QString,int)));
    connect(musicPage, SIGNAL(removeAllMusics(QString)), this, SLOT(removeAllMusics(QString)));
    connect(musicPage, SIGNAL(moveMusic(QString,int,int)), this, SLOT(moveMusic(QString,int,int)));

    bottomBar = new BottomBar(this);
    connect(bottomBar, SIGNAL(setVoice(int)), player, SLOT(setVoice(int)));
    connect(bottomBar, SIGNAL(setMode(int)), player, SLOT(setPlayMode(int)));
    connect(bottomBar, SIGNAL(setPostion(qint64)), player, SLOT(setPosition(qint64)));
    connect(bottomBar, SIGNAL(setPostion(qint64)), lyricLabel, SLOT(setPostion(qint64)));
    connect(player, SIGNAL(durationChanged(qint64)), bottomBar, SLOT(setMaxDuration(qint64)));
    connect(player, SIGNAL(positionChanged(qint64)), bottomBar, SLOT(changePostionTo(qint64)));
    connect(musicPage, SIGNAL(play(QString,int)), bottomBar, SLOT(setPostionAvailable()));
    connect(bottomBar, SIGNAL(tryplay()), this, SLOT(clickPlay()));
    connect(bottomBar, SIGNAL(playPre()), this, SLOT(playPre()));
    connect(bottomBar, SIGNAL(playNext()), this, SLOT(playNext()));
    connect(systemTrayIcon, SIGNAL(setMode(int)), bottomBar, SLOT(setPlayMode(int)));
    connect(bottomBar, SIGNAL(setMode(int)), systemTrayIcon, SLOT(setPlayMode(int)));
    connect(bottomBar, SIGNAL(showLyric(QString)), topBar, SLOT(changeFuction(QString)));
    //connect(lyricLabel, SIGNAL(changeTo(qint64)), bottomBar, SLOT(changePostionTo(qint64)));
    //connect(lyricLabel, SIGNAL(changeTo(qint64)), bottomBar, SIGNAL(setPostion(qint64)));

    QVBoxLayout *mainLayout = new QVBoxLayout;
    mainLayout->addWidget(topBar);

    QSplitter *splitter = new QSplitter(Qt::Horizontal, this);
    //设定分割窗口的分割条在拖动时是否为实时更新 true为实时更新 false则在拖动时只显示一条灰色的线条
    //在拖动到位并弹起鼠标后再显示分隔条
    splitter->setOpaqueResize(false);
    splitter->setChildrenCollapsible(false);
    splitter->addWidget(fuctionPage);
    splitter->addWidget(musicPage);
    splitter->setStretchFactor(0, 10);
    splitter->setStretchFactor(1, 1);
    splitter->setStyleSheet("QSplitter::handle { background-color: rgba(0,0,0,0%) }");
    splitter->setHandleWidth(4);
    mainLayout->addWidget(splitter);
    mainLayout->addWidget(bottomBar);
    mainLayout->setMargin(1);
    mainLayout->setSpacing(3);
    this->setLayout(mainLayout);

    dealMouse();
    readData();
}
Beispiel #16
0
LatexLogWidget::LatexLogWidget(QWidget *parent) :
    QWidget(parent), logModel(0), displayPartsActions(0),filterErrorAction(0),filterWarningAction(0),filterBadBoxAction(0),logpresent(false)
{
	logModel = new LatexLogModel(this);//needs loaded line marks

	errorTable = new QTableView(this);
	int rowHeight = getOptimalRowHeight(errorTable);
	errorTable->verticalHeader()->setDefaultSectionSize(rowHeight);
	QFontMetrics fm(QApplication::font());
	errorTable->setSelectionBehavior(QAbstractItemView::SelectRows);
	errorTable->setSelectionMode(QAbstractItemView::SingleSelection);
	errorTable->setColumnWidth(0,fm.width("> "));
	errorTable->setColumnWidth(1,20*fm.width("w"));
	errorTable->setColumnWidth(2,fm.width("WarningW"));
	errorTable->setColumnWidth(3,fm.width("Line WWWWW"));
	errorTable->setColumnWidth(4,20*fm.width("w"));
	connect(errorTable, SIGNAL(clicked(const QModelIndex &)), this, SLOT(clickedOnLogModelIndex(const QModelIndex &)));

	errorTable->horizontalHeader()->setStretchLastSection(true);
	errorTable->setMinimumHeight(5*rowHeight);
	errorTable->setFrameShape(QFrame::NoFrame);
	errorTable->setSortingEnabled(true);

	proxyModel = new QSortFilterProxyModel(this);
	proxyModel->setSourceModel(logModel);
	errorTable->setModel(proxyModel);

	QAction * act = new QAction(tr("&Copy"),errorTable);
	connect(act, SIGNAL(triggered()), SLOT(copyMessage()));
	errorTable->addAction(act);
	act = new QAction(tr("&Copy All"),errorTable);
	connect(act, SIGNAL(triggered()), SLOT(copyAllMessages()));
	errorTable->addAction(act);
	act = new QAction(tr("&Copy All With Line Numbers"),errorTable);
	connect(act, SIGNAL(triggered()), SLOT(copyAllMessagesWithLineNumbers()));
	errorTable->addAction(act);
	errorTable->setContextMenuPolicy(Qt::ActionsContextMenu);

	log = new LogEditor(this);
	log->setFocusPolicy(Qt::ClickFocus);
	log->setMinimumHeight(3*(fm.lineSpacing()+4));
	log->setReadOnly(true);
	connect(log, SIGNAL(clickOnLogLine(int)),this,SLOT(gotoLogLine(int)));

	QSplitter *splitter = new QSplitter(Qt::Vertical, this);
	splitter->setChildrenCollapsible(false);
	splitter->addWidget(errorTable);
	splitter->addWidget(log);

	infoLabel = new QLabel(tr("No log file available"), this);
	infoLabel->setStyleSheet("background: #FFFBBF;");
	infoLabel->setMargin(2);

	QVBoxLayout* vLayout = new QVBoxLayout(); //contains the widgets for the normal mode (OutputTable + OutputLogTextEdit)
	vLayout->setSpacing(0);
	vLayout->setMargin(0);
	vLayout->addWidget(infoLabel);
	vLayout->addWidget(splitter);
	setLayout(vLayout);

	displayPartsActions = new QActionGroup(this);
	displayPartsActions->setExclusive(true);
	connect(displayPartsActions, SIGNAL(triggered(QAction*)), this, SLOT(changeDisplay(QAction *)));
	displayTableAction = new QAction(tr("Issues"), displayPartsActions);
	displayTableAction->setData(qVariantFromValue(DisplayTable));
	displayTableAction->setCheckable(true);
	displayLogAction = new QAction(tr("Log File"), displayPartsActions);
	displayLogAction->setData(qVariantFromValue(DisplayLog));
	displayLogAction->setCheckable(true);
	displayLogAndTableAction = new QAction(tr("Issues and Log"), displayPartsActions);
	displayLogAndTableAction->setData(qVariantFromValue(DisplayLogAndTable));
	displayLogAndTableAction->setCheckable(true);
    filterErrorAction = new QAction(QIcon(":/images-ng/error.svgz"),tr("Show Error"),this);
    filterErrorAction->setCheckable(true);
    filterErrorAction->setChecked(true);
    connect(filterErrorAction,SIGNAL(toggled(bool)),this,SLOT(filterChanged(bool)));
    filterWarningAction = new QAction(QIcon(":/images-ng/warning.svgz"),tr("Show Warning"),this);
    filterWarningAction->setCheckable(true);
    filterWarningAction->setChecked(true);
    connect(filterWarningAction,SIGNAL(toggled(bool)),this,SLOT(filterChanged(bool)));
    filterBadBoxAction = new QAction(QIcon(":/images-ng/badbox.svg"),tr("Show BadBox"),this);
    filterBadBoxAction->setCheckable(true);
    filterBadBoxAction->setChecked(true);
    connect(filterBadBoxAction,SIGNAL(toggled(bool)),this,SLOT(filterChanged(bool)));

	setDisplayParts(DisplayTable);
}
Beispiel #17
0
int main(int argc, char *argv[])
{
	QApplication app(argc, argv);
	// cria um objeto "splitter" para compartilhar widgets:    
	QSplitter *splitter = new QSplitter(Qt::Horizontal); // horizontal e o default...

	// cria um "model" usando o "QDirModel"
	QDirModel *model = new QDirModel(&app); // será deletado
												// na destrutora de QApplication (QObject)
//	model->setFilter(QDir::Dirs  | QDir::Files | QDir::NoDotAndDotDot);
//	model->setNameFilters(QStringList() << "cursoQt");

	// Neste exemplo,
	// O "model" será configurado para pegar dados 
	// a partir de determinado(s) drive(s) ou diretório(s).
	// E serão criadas três "views" (uma "tree", uma "table", e uma "list" )
	// relacionadas ao mesmo "model";
	// Cada "view" exibe os dados de uma determinada maneira;

	// 1- ==== a primeira "view" é uma "tree":
	QTreeView *tree = new QTreeView(splitter);
	tree->setModel(model);
	
	// O DirModel já oferece um "RootIndex" a partir do qual
	// cada "view" exibe drives, diretórios e arquivos abaixo dele.
	// No Windows o "RootIndex" default exibirá
	// a relacão de todos os drives; 
	// para outros Sistemas apenas o root ('/').

	// Mas podemos alterar o "RootIndex" de cada view.
	
	// Um exemplo: partindo do diretório atual:
	//    tree->setRootIndex(model->index(QDir::currentPath()));
		 #ifdef Q_OS_WIN
			 QString rootNdx("C:/cursoQt");
		 #else
			 QString rootNdx("/home/user_name/cursoQt");
		#endif
	
	//	tree->setRootIndex(model->index(rootNdx));

	// MAS, temos a função que develve o root do SO:
	// outro exemplo: partindo do diretorio "root" ( "/" ou "C:/"):
	//    tree->setRootIndex(model->index(QDir::rootPath()));
	// ou ainda, um diretório específico:
	//    tree->setRootIndex(model->index("/cursoqt"));
	 // tree->setRootIndex(model->index("/cursoqt"));
	/*	
		// outro exemplo: partindo de determinado drive:
		QFileInfoList fiList = QDir::drives();
		foreach( const QFileInfo & fi, fiList )
		{	
			if ( fi.filePath()=="D:/" ) // apenas o drive "D:/"
			{
				tree->setRootIndex(model->index(fi.filePath()));
				break;
			}				
		}		
	*/
	
	// 2- ==== a segunda "view" é uma "table"
	QTableView *table = new QTableView(splitter);

	table->setModel(model);
	//    table->setRootIndex(...); // idem

	// 3- ==== a terceira "view" é uma "list": 
	QListView *list = new QListView(splitter);
	list->setModel(model);
	//list->setRootIndex(model->index(rootNdx)); // idem

	// configura e exibe a "splitter"
	splitter->setWindowTitle("00_dir - 3 'views' usando o mesmo 'model' (diretórios)");
	int width=800;	
	splitter->resize(width,500);	
	
	// largura de cada "view"
	QList< int > cols;
	cols << int(width* 0.45) << int(width*0.45) << int(width*0.1); 
	splitter->setSizes(cols);	
	
	splitter->setChildrenCollapsible(false); // impede que cada banda colapse totalmente
	
	splitter->show();
	int ret  = app.exec();
	delete splitter;  // porque não alocou o splitter na PILHA ????

	return ret;
}
Beispiel #18
0
SinglePopupEditor::SinglePopupEditor(QWidget * par)
    : QWidget(par)
{
	m_pLastSelectedItem = nullptr;
	m_pContextPopup = new QMenu(this);
	m_pClipboard = nullptr;
	m_pTestPopup = nullptr;

	QGridLayout * g = new QGridLayout(this);
	g->setMargin(0);
	g->setSpacing(2);

	m_pNameEditor = new QLineEdit(this);
	m_pNameEditor->setToolTip(__tr2qs_ctx("Popup name", "editor"));

	g->addWidget(m_pNameEditor, 0, 0, 1, 2);

	m_pMenuButton = new QPushButton(__tr2qs_ctx("Test", "editor"), this);
	g->addWidget(m_pMenuButton, 0, 2);
	connect(m_pMenuButton, SIGNAL(clicked()), this, SLOT(testPopup()));
	QSplitter * spl = new QSplitter(Qt::Vertical, this);
	spl->setObjectName("popupeditor_vertical_splitter");
	spl->setChildrenCollapsible(false);

	m_pTreeWidget = new QTreeWidget(spl);
	m_pTreeWidget->setColumnCount(2);
	QStringList labels;
	labels << __tr2qs_ctx("Item", "editor") << __tr2qs_ctx("Type", "editor");
	m_pTreeWidget->setHeaderLabels(labels);
	m_pTreeWidget->setSelectionMode(QAbstractItemView::SingleSelection);
	m_pTreeWidget->setSelectionBehavior(QAbstractItemView::SelectRows);
	m_pTreeWidget->setAllColumnsShowFocus(true);
	m_pTreeWidget->setRootIsDecorated(true);
	m_pTreeWidget->header()->setSortIndicatorShown(false);
	m_pTreeWidget->setSortingEnabled(false);
	m_pTreeWidget->setContextMenuPolicy(Qt::CustomContextMenu);

	connect(m_pTreeWidget, SIGNAL(itemSelectionChanged()), this, SLOT(selectionChanged()));
	connect(m_pTreeWidget, SIGNAL(customContextMenuRequested(const QPoint &)),
	    this, SLOT(customContextMenuRequested(const QPoint &)));

	m_pEditor = KviScriptEditor::createInstance(spl);

	g->addWidget(spl, 1, 0, 1, 3);

	QLabel * l = new QLabel(__tr2qs_ctx("Text:", "editor"), this);
	g->addWidget(l, 2, 0);

	m_pTextEditor = new QLineEdit(this);
	m_pTextEditor->setToolTip(
	    __tr2qs_ctx("<b>Visible text</b><br>May contain identifiers that will be evaluated at popup call time.<br>For labels, this text can contain also limited HTML tags.", "editor"));
	g->addWidget(m_pTextEditor, 2, 1, 1, 2);

	l = new QLabel(__tr2qs_ctx("Condition:", "editor"), this);
	l->setMargin(2);
	g->addWidget(l, 3, 0);

	m_pConditionEditor = new QLineEdit(this);
	m_pConditionEditor->setToolTip(
	    __tr2qs_ctx("<b>Boolean condition</b><br>Will be evaluated at popup call time in order to decide if this entry has to be shown.<br>An empty condition evaluates to true.", "editor"));
	g->addWidget(m_pConditionEditor, 3, 1, 1, 2);

	l = new QLabel(__tr2qs_ctx("Icon:", "editor"), this);
	l->setMargin(2);
	g->addWidget(l, 4, 0);

	m_pIconEditor = new QLineEdit(this);
	m_pIconEditor->setToolTip(
	    __tr2qs_ctx("<b>Icon identifier</b><br>May be an internal icon ID, an absolute path or a relative path.<br>Portable scripts should never use absolute paths.", "editor"));
	g->addWidget(m_pIconEditor, 4, 1, 1, 2);

	l = new QLabel(__tr2qs_ctx("External menu:", "editor"), this);
	l->setMargin(2);
	g->addWidget(l, 5, 0);

	m_pExtNameEditor = new QLineEdit(this);
	m_pExtNameEditor->setToolTip(
	    __tr2qs_ctx("<b>External menu name</b><br>This allows one to nest externally defined popup menus. The popup menu with the specified name will be looked up at menu setup time.", "editor"));
	g->addWidget(m_pExtNameEditor, 5, 1, 1, 2);

	l = new QLabel(__tr2qs_ctx("Item ID:", "editor"), this);
	l->setMargin(2);
	g->addWidget(l, 6, 0);

	m_pIdEditor = new QLineEdit(this);
	m_pIdEditor->setToolTip(
	    __tr2qs_ctx("<b>Item ID</b><br>This will allow you to use delpopupitem later.", "editor"));
	g->addWidget(m_pIdEditor, 6, 1, 1, 2);
	g->setColumnStretch(1, 1);
	g->setRowStretch(1, 1);
}
Beispiel #19
0
MainWindow::MainWindow() :
	m_workspace( NULL ),
	m_templatesMenu( NULL ),
	m_recentlyOpenedProjectsMenu( NULL ),
	m_toolsMenu( NULL ),
	m_autoSaveTimer( this ),
	m_viewMenu( NULL ),
	m_metronomeToggle( 0 ),
	m_session( Normal )
{
	setAttribute( Qt::WA_DeleteOnClose );

	QWidget * main_widget = new QWidget( this );
	QVBoxLayout * vbox = new QVBoxLayout( main_widget );
	vbox->setSpacing( 0 );
	vbox->setMargin( 0 );

	QWidget * w = new QWidget( main_widget );
	QHBoxLayout * hbox = new QHBoxLayout( w );
	hbox->setSpacing( 0 );
	hbox->setMargin( 0 );

	SideBar * sideBar = new SideBar( Qt::Vertical, w );

	QSplitter * splitter = new QSplitter( Qt::Horizontal, w );
	splitter->setChildrenCollapsible( false );

	ConfigManager* confMgr = ConfigManager::inst();

	emit initProgress(tr("Preparing plugin browser"));
	sideBar->appendTab( new PluginBrowser( splitter ) );
	emit initProgress(tr("Preparing file browsers"));
	sideBar->appendTab( new FileBrowser(
				confMgr->userProjectsDir() + "*" +
				confMgr->factoryProjectsDir(),
					"*.mmp *.mmpz *.xml *.mid",
							tr( "My Projects" ),
					embed::getIconPixmap( "project_file" ).transformed( QTransform().rotate( 90 ) ),
							splitter, false, true ) );
	sideBar->appendTab( new FileBrowser(
				confMgr->userSamplesDir() + "*" +
				confMgr->factorySamplesDir(),
					"*", tr( "My Samples" ),
					embed::getIconPixmap( "sample_file" ).transformed( QTransform().rotate( 90 ) ),
							splitter, false, true ) );
	sideBar->appendTab( new FileBrowser(
				confMgr->userPresetsDir() + "*" +
				confMgr->factoryPresetsDir(),
					"*.xpf *.cs.xml *.xiz",
					tr( "My Presets" ),
					embed::getIconPixmap( "preset_file" ).transformed( QTransform().rotate( 90 ) ),
							splitter , false, true  ) );
	sideBar->appendTab( new FileBrowser( QDir::homePath(), "*",
							tr( "My Home" ),
					embed::getIconPixmap( "home" ).transformed( QTransform().rotate( 90 ) ),
							splitter, false, false ) );


	QStringList root_paths;
	QString title = tr( "Root directory" );
	bool dirs_as_items = false;

#ifdef LMMS_BUILD_APPLE
	title = tr( "Volumes" );
	root_paths += "/Volumes";
#elif defined(LMMS_BUILD_WIN32)
	title = tr( "My Computer" );
	dirs_as_items = true;
#endif

#if ! defined(LMMS_BUILD_APPLE)
	QFileInfoList drives = QDir::drives();
	for( const QFileInfo & drive : drives )
	{
		root_paths += drive.absolutePath();
	}
#endif

	sideBar->appendTab( new FileBrowser( root_paths.join( "*" ), "*", title,
					embed::getIconPixmap( "computer" ).transformed( QTransform().rotate( 90 ) ),
							splitter, dirs_as_items) );

	m_workspace = new QMdiArea( splitter );

	// Load background
	emit initProgress(tr("Loading background artwork"));
	QString bgArtwork = ConfigManager::inst()->backgroundArtwork();
	QImage bgImage;
	if( !bgArtwork.isEmpty() )
	{
		bgImage = QImage( bgArtwork );
	}
	if( !bgImage.isNull() )
	{
		m_workspace->setBackground( bgImage );
	}
	else
	{
		m_workspace->setBackground( Qt::NoBrush );
	}

	m_workspace->setOption( QMdiArea::DontMaximizeSubWindowOnActivation );
	m_workspace->setHorizontalScrollBarPolicy( Qt::ScrollBarAsNeeded );
	m_workspace->setVerticalScrollBarPolicy( Qt::ScrollBarAsNeeded );

	hbox->addWidget( sideBar );
	hbox->addWidget( splitter );


	// create global-toolbar at the top of our window
	m_toolBar = new QWidget( main_widget );
	m_toolBar->setObjectName( "mainToolbar" );
	m_toolBar->setFixedHeight( 64 );
	m_toolBar->move( 0, 0 );

	// add layout for organizing quite complex toolbar-layouting
	m_toolBarLayout = new QGridLayout( m_toolBar/*, 2, 1*/ );
	m_toolBarLayout->setMargin( 0 );
	m_toolBarLayout->setSpacing( 0 );

	vbox->addWidget( m_toolBar );
	vbox->addWidget( w );
	setCentralWidget( main_widget );

	m_updateTimer.start( 1000 / 20, this );  // 20 fps

	if( !ConfigManager::inst()->value( "ui", "disableautosave" ).toInt() )
	{
		// connect auto save
		connect(&m_autoSaveTimer, SIGNAL(timeout()), this, SLOT(autoSave()));
		m_autoSaveInterval = ConfigManager::inst()->value(
					"ui", "saveinterval" ).toInt() < 1 ?
						DEFAULT_AUTO_SAVE_INTERVAL :
				ConfigManager::inst()->value(
					"ui", "saveinterval" ).toInt();

		// The auto save function mustn't run until there is a project
		// to save or it will run over recover.mmp if you hesitate at the
		// recover messagebox for a minute. It is now started in main.
		// See autoSaveTimerReset() in MainWindow.h
	}

	connect( Engine::getSong(), SIGNAL( playbackStateChanged() ),
				this, SLOT( updatePlayPauseIcons() ) );
}
Beispiel #20
0
Caisse::Caisse(QMainWindow *parent) :
    QWidget(parent)
{
    QGridLayout *layout = new QGridLayout(this);
    QSplitter *splitter = new QSplitter(this);
    layout->addWidget(splitter);
    splitter->setChildrenCollapsible( false );
        QWidget *widgetGauche = new QWidget(this);
        QVBoxLayout *layout_gauche = new QVBoxLayout(widgetGauche);
        splitter->addWidget(widgetGauche);
        QWidget *widgetCentre = new QWidget(this);
        QGridLayout *layout_centre = new QGridLayout(widgetCentre);
        splitter->addWidget(widgetCentre);
        QWidget *widgetDroite = new QWidget(this);
        QVBoxLayout *layout_droite = new QVBoxLayout(widgetDroite);
        splitter->addWidget(widgetDroite);


    // On construit le tableau avec tous les bouton clients
    m_promo="125";
    m_nombrecolonne=3;
    m_nombreligne=1;
    listClient = getListClient(m_promo,m_nombreligne * m_nombrecolonne);

    //On construit le layout de gauche en commencant par l'affichage du client en cours
    m_widgetClient = new WidgetClient(listClient[0],this);
    layout_gauche->addWidget(m_widgetClient);

    for (int i=0; i<m_nombreligne * m_nombrecolonne ; i++) {
        listWidgetBoutonClient.push_back(new WidgetBoutonClient(listClient[i],this));
        connect(listWidgetBoutonClient[i],SIGNAL(clicked(Client*)),this,SLOT(changerClient(Client*)));
        connect(listClient[i],SIGNAL(changed()),listWidgetBoutonClient[i],SLOT(update()));
        layout_centre->addWidget(listWidgetBoutonClient[i],i/m_nombrecolonne,i%m_nombrecolonne);
    }

    // On construit la liste des consommations
    listConso = getListConso();
    for (int i=0; i<listConso.size(); i++)
    {
        listWidgetConso.push_back(new WidgetConso(listConso[i],this));
        connect(listWidgetConso[i],SIGNAL(clicked(Conso*,int)),this,SLOT(changerSoldeConso(Conso*,int)));
        layout_gauche->addWidget(listWidgetConso[i]);
    }

    // On construit les boutons de pages et de promo

    QGroupBox *boxPromo = new QGroupBox("Promotion",this);
    QVBoxLayout *layoutBoxPromo = new QVBoxLayout(boxPromo);
    layout_droite->addWidget(boxPromo);
    listPromo = getListPromo(this);
    for (int i=0; i<listPromo.size(); i++) {
        layoutBoxPromo->addWidget(listPromo[i]);
        connect(listPromo[i],SIGNAL(clicked(QString)),this,SLOT(changerPromo(QString)));
    }

    boxPage = new QGroupBox("Promo " + m_promo ,this);
    layoutBoxPage = new QVBoxLayout(boxPage);
    layout_droite->addWidget(boxPage);
    listPage = getListPage(this, m_promo, m_nombreligne * m_nombrecolonne);
    for (int i=0; i<listPage.size(); i++) {
        layoutBoxPage->addWidget(listPage[i]);
        connect(listPage[i],SIGNAL(clicked(QString)),this,SLOT(changerPage(QString)));
    }

}