Ejemplo n.º 1
0
void KisColorSelector::init()
{
    setAcceptDrops(true);

    m_lastColorRole = Acs::Foreground;
    m_ring = new KisColorSelectorRing(this);
    m_triangle = new KisColorSelectorTriangle(this);
    m_slider = new KisColorSelectorSimple(this);
    m_square = new KisColorSelectorSimple(this);
    m_wheel = new KisColorSelectorWheel(this);

    if(displaySettingsButton()) {
        m_button = new QPushButton(this);
        m_button->setIcon(koIcon("configure"));
        connect(m_button, SIGNAL(clicked()), SIGNAL(settingsButtonClicked()));
    }

    // a tablet can send many more signals, than a mouse
    // this causes many repaints, if updating after every signal.
    m_signalCompressor = new KisSignalCompressor(20, KisSignalCompressor::FIRST_INACTIVE, this);
    connect(m_signalCompressor, SIGNAL(timeout()), SLOT(update()));

    setMinimumSize(40, 40);
}
Ejemplo n.º 2
0
QFrame* MainWindow::initFilesListFrame(QWidget *parent)
{
    QScrollArea *scrollFrame = new QScrollArea(parent);
    QFrame *frame = new QFrame(scrollFrame);

    QVBoxLayout *layout = new QVBoxLayout(frame);

    layout->setContentsMargins(0, 0, 0, 0);
    layout->setAlignment(Qt::AlignTop);
    layout->addWidget(filesListWidget);
    layout->addSpacing(25);
    layout->addWidget(initDragFrame(frame), 0, Qt::AlignHCenter);
    layout->addSpacing(25);

    scrollFrame->setWidget(frame);
    scrollFrame->setAcceptDrops(true);
    scrollFrame->installEventFilter(this);
    scrollFrame->setWidgetResizable(true);
    scrollFrame->setStyleSheet("QFrame {"
                               "border: none;"
                               "}"
                               "QScrollBar:vertical {"
                               "background: white;"
                               "width: 8px;"
                               "}"
                               "QScrollBar::handle:vertical {"
                               "background: grey;"
                               "min-height: 20px;"
                               "}"
                               "QScrollBar::add-line:vertical, QScrollBar::sub-line:vertical {"
                               "width: 0px;"
                               "height: 0px;"
                               "}");

    QFrame *mainFrame = new QFrame(parent);
    QVBoxLayout *mainLayout = new QVBoxLayout(mainFrame);
    FixedHeaderView *headerView = new FixedHeaderView(Qt::Horizontal, mainFrame);
    headerView->setModel(new FilesListModel(filesList, this));
    headerView->setStyleSheet("QHeaderView::section {"
                              "background: transparent;"
                              "border-style: none;"
                              "border-bottom: 1px solid rgb(207, 207, 207);"
                              "border-right: 1px solid rgb(207, 207, 207);"
                              "}"
                              "QWidget {"
                              "font: bold 11px \"Arial\";"
                              "color: rgb(58, 58, 58);"
                              "}");
    headerView->setFixedHeight(30);
    headerView->setMinimumSectionSize(150);
    headerView->resizeSection(0, 250);
    headerView->resizeSection(1, 400);
    headerView->setFixedHeight(30);

    mainLayout->setMargin(0);
    mainLayout->setSpacing(0);
    mainLayout->addWidget(headerView);
    mainLayout->addWidget(scrollFrame);

    connect(headerView, SIGNAL(sectionResized(int,int,int)), filesListWidget, SLOT(resizeSection(int, int, int)));
    connect(headerView, SIGNAL(settingsButtonClicked()), SIGNAL(incrementSettingsClicked()));
    //connect(headerView, &FixedHeaderView::settingsButtonClicked, this, [=](){ initSettingsFrame(); });

    connect(filesListWidget, &FilesListWidget::fileSelected, this, [=](int index)
    {
        if (index >= 0)
        {
            QRect rect = filesListWidget->visualRect(filesListWidget->currentIndex());

            scrollFrame->ensureVisible(rect.x(), rect.y() + rect.height(), 0, rect.height());
        }
    });

    return mainFrame;
}
Ejemplo n.º 3
0
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    settingsOpen = false;
    onSave = 0;
    QDir home(QDir::homePath()+"/parserYandex/");
    QDir homeSaved(QDir::homePath()+"/parserYandex/saved/");
    if (!home.exists())
        home.mkpath(QDir::homePath()+"/parserYandex/");
    if (!homeSaved.exists())
        home.mkpath(QDir::homePath()+"/parserYandex/saved");
    path = QDir::homePath()+"/parserYandex/saved/";
    ui->setupUi(this);
    ui->settingsButton->setIcon(QIcon(":/icons/settings.png"));
    ui->settingsButton->setFixedSize(24,24);
    ui->settingsButton->setStyleSheet(
            "QPushButton {"
                "image: url(:/icons/settings.png); "
                "border: none;"
            "}"
            "QPushButton:hover {"
                "image: url(:/icons/settings_pressed.png);"
            "}"
            "QPushButton:pressed {"
                "image: url(:/icons/settings_pressed.png);"
            "}"
            "QPushButton:focus {"
                "border: none;"
           "}"

);
    ui->enterButton->setIcon(QIcon(":/icons/clear.png"));
    ui->enterButton->setFixedSize(20,20);
    ui->enterButton->setStyleSheet(
            "QPushButton {"
                "image: url(:/icons/clear.png); "
                "border: none;"
            "}"
            "QPushButton:hover {"
                "image: url(:/icons/clear_pressed.png);"
            "}"
            "QPushButton:pressed {"
                "image: url(:/icons/clear.png);"
            "}"
            "QPushButton:focus {"
                "border: none;"
           "}"

);
    this->resize(QSize(630,166));
    ui->yandexBox->setChecked(true);
    ui->progressBar->hide();
    ui->autoCompletion->hide();
    ui->autoCompletion->setResizeMode(QListView::Adjust);
    ui->settings->hide();
    ui->settings_arrow->hide();
    ui->resultTable->hide();
    ui->label->setText(QString("История пуста. Начни менять историю прямо сейчас."));
    ui->newWindow->setShortcut(Qt::Key_Control+Qt::Key_N);
    ui->newWindow->setEnabled(true);
    ui->exit->setShortcuts(QKeySequence::Quit);

    manager = new QNetworkAccessManager(this);

    connect(ui->exit, SIGNAL(triggered()), qApp, SLOT(closeAllWindows()));
    connect(ui->newWindow, SIGNAL(triggered()), this, SLOT(newWindow()));
    connect(ui->searchString, SIGNAL(returnPressed()), this, SLOT(sendString()));
    connect(ui->settingsButton, SIGNAL(clicked()), this, SLOT(settingsButtonClicked()));
    connect(ui->enterButton, SIGNAL(clicked()), this, SLOT(clearString()));
    connect(ui->about, SIGNAL(triggered()), this, SLOT(showAuthor()));
    connect(ui->help, SIGNAL(triggered()), this, SLOT(showHowToUse()));
    connect(ui->searchString, SIGNAL(textEdited(QString)), this, SLOT(getAutoComplition(QString)));

    initTest();
}