Beispiel #1
0
void MainWindow::statusBarCreate(void)
{
	m_statusPositionLabel = new QLabel(this);
	m_statusPositionLabel->setAlignment(Qt::AlignHCenter);
	m_statusPositionLabel->setFrameStyle(QFrame::Panel | QFrame::Sunken);
	m_statusPositionLabel->setLineWidth(1);

	m_statusMessageLabel = new QLabel(this);
	m_statusMessageLabel->setAlignment(Qt::AlignLeft);
	m_statusMessageLabel->setIndent(3);
	m_statusMessageLabel->setFrameStyle(QFrame::Panel | QFrame::Sunken);
	m_statusMessageLabel->setLineWidth(1);

	statusBar()->addWidget(m_statusPositionLabel);
	statusBar()->addWidget(m_statusMessageLabel, 1);

	connect(m_editBox, SIGNAL(cursorChanged()),
		this, SLOT(statusBarUpdate()));

	m_statusReady = true;
}
Beispiel #2
0
void tpMainWindow::setupModelsViews()
{
    AgtvDefItemDelegate =  new AgtvDefaultItemDelegate();

    QStringList horzHeaders = { "Name", "Status", "#V", "#F",
                                "Game", "Status Message"};

    stmodel = new TwitchChannelModel(this, genericHelper::getUpdateIntervalMsec());
    stmodel->setHorizontalHeaderLabels(horzHeaders);
    QObject::connect(stmodel, SIGNAL(notifyByTray(QString, QString)),
                     this, SLOT(on_notifyByTray(QString, QString)));
    QObject::connect(stmodel, SIGNAL(notifyByTray(QString, QString)),
                     this, SLOT(statusBarUpdate()));
    stproxymodel = new AdvQSortFilterProxyModel(this);
    stproxymodel->setSourceModel(stmodel);
    stproxymodel->setFilterCaseSensitivity(Qt::CaseInsensitive);

    this->ui->tableView->horizontalHeader()->show();
    this->ui->tableView->setItemDelegate(AgtvDefItemDelegate);
    this->ui->tableView->setModel(stproxymodel);

    stmodelbookmarks = new TwitchChannelModel(this, genericHelper::getUpdateIntervalMsec());
    QObject::connect(stmodelbookmarks, SIGNAL(notifyByTray(QString, QString)),
                     this, SLOT(on_notifyByTray(QString, QString)));
    QObject::connect(stmodelbookmarks, SIGNAL(notifyByTray(QString, QString)),
                     this, SLOT(statusBarUpdate()));
    stmodelbookmarks->setHorizontalHeaderLabels(horzHeaders);
    stproxymodelbookmarks = new AdvQSortFilterProxyModel(this);
    stproxymodelbookmarks->setSourceModel(stmodelbookmarks);
    stproxymodelbookmarks->setFilterCaseSensitivity(Qt::CaseInsensitive);

    this->ui->tableViewBookmarks->horizontalHeader()->show();
    this->ui->tableViewBookmarks->setItemDelegate(AgtvDefItemDelegate);
    this->ui->tableViewBookmarks->setModel(stproxymodelbookmarks);

    if (genericHelper::getShowOfflineStreamers() == true) {
        this->stproxymodel->setShowOffline(true);
        this->stproxymodelbookmarks->setShowOffline(true);
        this->ui->actionShow_Offline_Streamers->setChecked(true);
    } else {
        this->stproxymodel->setShowOffline(false);
        this->stproxymodelbookmarks->setShowOffline(false);
        this->ui->actionShow_Offline_Streamers->setChecked(false);
    }

    this->stproxymodel->setShowApproximateViewerCount(genericHelper::getShowApproximateViewerCount());
    this->stproxymodelbookmarks->setShowApproximateViewerCount(genericHelper::getShowApproximateViewerCount());
    this->ui->actionShow_Approximate_Viewer_Count->setChecked(genericHelper::getShowApproximateViewerCount());

    if(! genericHelper::getShowFollowerCount()) {
        this->ui->tableView->hideColumn((qint64)TwitchChannelModel::ColumnIndex::followers);
        this->ui->tableViewBookmarks->hideColumn((qint64)TwitchChannelModel::ColumnIndex::followers);
    }
    this->ui->actionShow_Follower_Count->setChecked(genericHelper::getShowFollowerCount());

    ui->tableView->horizontalHeader()->setStretchLastSection(genericHelper::getFitAllContentToWindow());
    ui->tableViewBookmarks->horizontalHeader()->setStretchLastSection(genericHelper::getFitAllContentToWindow());

    if(! genericHelper::getFitAllContentToWindow()) {
        QTimer::singleShot(0, this, SLOT(restoreTableViewsManual()));
    }

    QTimer::singleShot(0, this, SLOT(restoreSortModes()));
}
Beispiel #3
0
MainWindow::MainWindow(QWidget *parent) :
	QMainWindow(parent),
	ui(new Ui::MainWindow)
{
	m_commandLine = new CommandLine(qApp->arguments());
	if (m_commandLine->processed())
	{
		// don't start GUI and retrieve the return code
		m_guiActive = false;
		m_returnCode = m_commandLine->returnCode();
		return;
	}

	// start GUI here
	ui->setupUi(this);
	m_recentPrograms = new RecentFiles(ui->menuOpenRecent, this);
	connect(m_recentPrograms, SIGNAL(openFile(QString)),
		this, SLOT(programOpen(const QString)));
	settingsRestore();

	// TODO settings will eventually have info about edit boxes that were open
	// TODO that will need to be restored, for now there is a single edit box

	//==================
	//  SETUP EDIT BOX
	//==================

	// create the starting program edit box
	m_editBox = new EditBox(this);
	setCentralWidget(m_editBox);
	m_statusReady = false;

	connect(m_editBox->document(), SIGNAL(modificationChanged(bool)),
		this, SLOT(setWindowModified(bool)));
	connect(m_editBox->document(), SIGNAL(modificationChanged(bool)),
		ui->actionSave, SLOT(setEnabled(bool)));

	// connect available signals to the appropriate edit actions
	connect(m_editBox, SIGNAL(undoAvailable(bool)),
		ui->actionUndo, SLOT(setEnabled(bool)));
	connect(m_editBox, SIGNAL(redoAvailable(bool)),
		ui->actionRedo, SLOT(setEnabled(bool)));
	connect(m_editBox, SIGNAL(copyAvailable(bool)),
		ui->actionCut, SLOT(setEnabled(bool)));
	connect(m_editBox, SIGNAL(copyAvailable(bool)),
		ui->actionCopy, SLOT(setEnabled(bool)));
	connect(m_editBox, SIGNAL(copyAvailable(bool)),
		ui->actionDelete, SLOT(setEnabled(bool)));
	connect(m_editBox, SIGNAL(errorsAvailable(bool)),
		ui->actionGoNextError, SLOT(setEnabled(bool)));
	connect(m_editBox, SIGNAL(errorsAvailable(bool)),
		ui->actionGoPrevError, SLOT(setEnabled(bool)));

	// create actions for edit box context menu
	QList<QAction *> actions;
	actions.append(ui->actionUndo);
	actions.append(ui->actionRedo);
	actions.append(new QAction(m_editBox));
	actions.last()->setSeparator(true);
	actions.append(ui->actionCut);
	actions.append(ui->actionCopy);
	actions.append(ui->actionPaste);
	actions.append(ui->actionDelete);
	actions.append(new QAction(m_editBox));
	actions.last()->setSeparator(true);
	actions.append(ui->actionSelectAll);
	m_editBox->addActions(actions);
	m_editBox->setContextMenuPolicy(Qt::ActionsContextMenu);

	//==============================================
	// SETUP PROGRAM MODEL, LINE DELEGATE AND VIEW
	//==============================================

	// setup program model (connect to edit box changes)
	m_programModel = new ProgramModel(this);
	connect(m_editBox, SIGNAL(linesChanged(int, int, int, QStringList)),
		m_programModel, SLOT(update(int, int, int, QStringList)));
	connect(m_programModel, SIGNAL(errorListChanged(ErrorList)),
		m_editBox, SLOT(updateErrors(ErrorList)));

	// setup program line delegate (connect to model line count changes)
	m_programLineDelegate = new ProgramLineDelegate(EditBox::BaseLineNumber,
		ui->programView, this);
	connect(m_programModel, SIGNAL(lineCountChanged(int)),
		m_programLineDelegate, SLOT(lineNumberWidthUpdate(int)));

	// setup program view
	ui->programView->setItemDelegate(m_programLineDelegate);
	ui->programView->setModel(m_programModel);
	ui->programView->setFont(m_editBox->font());

	//=================
	//  SETUP PROGRAM
	//=================

	// if a file name was specified on the command line
	// then it overrides the restored program
	if (!m_commandLine->fileName().isEmpty())
	{
		setCurProgram(m_commandLine->fileName());
	}
	else
	{
		// make sure window title is set before continuing
		setCurProgram(m_curProgram);
	}

	// load program if one was saved or specified on command line
	if (!m_curProgram.isEmpty()						// load a program?
			&& (!QFile::exists(m_curProgram)		// program not found?
			|| !programLoad(m_curProgram))			// program not loaded?
			&& m_commandLine->fileName().isEmpty())	// no program argument
	{
		setCurProgram("");  // clear program path that was restored/set
		// TODO should an warning message be issued here?
	}
	statusBarCreate();

	m_guiActive = true;
	statusBarUpdate();
}