Game information dialog is now Qt's richtext example
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -1,19 +1,125 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <QDialog>
|
#include <QMainWindow>
|
||||||
|
#include <QMap>
|
||||||
|
#include <QPointer>
|
||||||
|
#include <QEventLoop>
|
||||||
|
|
||||||
#include <memory>
|
QT_BEGIN_NAMESPACE
|
||||||
|
class QAction;
|
||||||
|
class QComboBox;
|
||||||
|
class QFontComboBox;
|
||||||
|
class QTextEdit;
|
||||||
|
class QTextCharFormat;
|
||||||
|
class QMenu;
|
||||||
|
class QPrinter;
|
||||||
|
QT_END_NAMESPACE
|
||||||
|
|
||||||
namespace Ui { class GameInformationDialog; }
|
class GameInformationDialog : public QMainWindow
|
||||||
|
|
||||||
class GameInformationDialog : public QDialog
|
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit GameInformationDialog(QWidget *parent = nullptr);
|
GameInformationDialog(QWidget *parent = nullptr);
|
||||||
~GameInformationDialog();
|
|
||||||
|
bool load(const QString &f);
|
||||||
|
|
||||||
|
bool result() const;
|
||||||
|
|
||||||
|
void setResult(bool result);
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void finished(int result);
|
||||||
|
void accepted();
|
||||||
|
void rejected();
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
virtual void open();
|
||||||
|
virtual bool exec();
|
||||||
|
virtual void done(bool result);
|
||||||
|
virtual void accept();
|
||||||
|
virtual void reject();
|
||||||
|
|
||||||
|
void fileNew();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void closeEvent(QCloseEvent *e) override;
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void fileOpen();
|
||||||
|
bool fileSave();
|
||||||
|
bool fileSaveAs();
|
||||||
|
void filePrint();
|
||||||
|
void filePrintPreview();
|
||||||
|
void filePrintPdf();
|
||||||
|
|
||||||
|
void textBold();
|
||||||
|
void textUnderline();
|
||||||
|
void textItalic();
|
||||||
|
void textFamily(const QString &f);
|
||||||
|
void textSize(const QString &p);
|
||||||
|
void textStyle(int styleIndex);
|
||||||
|
void textColor();
|
||||||
|
void textAlign(QAction *a);
|
||||||
|
void setChecked(bool checked);
|
||||||
|
void indent();
|
||||||
|
void unindent();
|
||||||
|
|
||||||
|
void currentCharFormatChanged(const QTextCharFormat &format);
|
||||||
|
void cursorPositionChanged();
|
||||||
|
|
||||||
|
void clipboardDataChanged();
|
||||||
|
void about();
|
||||||
|
void printPreview(QPrinter *);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const std::unique_ptr<Ui::GameInformationDialog> m_ui;
|
void setupFileActions();
|
||||||
|
void setupEditActions();
|
||||||
|
void setupTextActions();
|
||||||
|
bool maybeSave();
|
||||||
|
void setCurrentFileName(const QString &fileName);
|
||||||
|
void modifyIndentation(int amount);
|
||||||
|
|
||||||
|
void mergeFormatOnWordOrSelection(const QTextCharFormat &format);
|
||||||
|
void fontChanged(const QFont &f);
|
||||||
|
void colorChanged(const QColor &c);
|
||||||
|
void alignmentChanged(Qt::Alignment a);
|
||||||
|
|
||||||
|
void resetModalitySetByOpen();
|
||||||
|
void finalize(bool resultCode, bool dialogCode);
|
||||||
|
void hide(bool result);
|
||||||
|
|
||||||
|
QAction *actionSave;
|
||||||
|
QAction *actionTextBold;
|
||||||
|
QAction *actionTextUnderline;
|
||||||
|
QAction *actionTextItalic;
|
||||||
|
QAction *actionTextColor;
|
||||||
|
QAction *actionAlignLeft;
|
||||||
|
QAction *actionAlignCenter;
|
||||||
|
QAction *actionAlignRight;
|
||||||
|
QAction *actionAlignJustify;
|
||||||
|
QAction *actionIndentLess;
|
||||||
|
QAction *actionIndentMore;
|
||||||
|
QAction *actionToggleCheckState;
|
||||||
|
QAction *actionUndo;
|
||||||
|
QAction *actionRedo;
|
||||||
|
#ifndef QT_NO_CLIPBOARD
|
||||||
|
QAction *actionCut;
|
||||||
|
QAction *actionCopy;
|
||||||
|
QAction *actionPaste;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
QComboBox *comboStyle;
|
||||||
|
QFontComboBox *comboFont;
|
||||||
|
QComboBox *comboSize;
|
||||||
|
|
||||||
|
QToolBar *tb;
|
||||||
|
QString fileName;
|
||||||
|
QTextEdit *textEdit;
|
||||||
|
|
||||||
|
QEventLoop eventLoop;
|
||||||
|
|
||||||
|
bool m_result{};
|
||||||
|
int m_resetModalityTo;
|
||||||
|
bool m_wasModalitySet;
|
||||||
};
|
};
|
||||||
|
@@ -13,7 +13,19 @@
|
|||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
<string>Game Information</string>
|
<string>Game Information</string>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout" stretch="0,0,1">
|
<layout class="QVBoxLayout" name="verticalLayout" stretch="0,0,0,1">
|
||||||
|
<property name="leftMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="topMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="rightMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="bottomMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QMenuBar" name="menuBar">
|
<widget class="QMenuBar" name="menuBar">
|
||||||
<widget class="QMenu" name="menuFile">
|
<widget class="QMenu" name="menuFile">
|
||||||
@@ -66,13 +78,16 @@
|
|||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QToolBar" name="toolBar">
|
<widget class="QToolBar" name="toolBar">
|
||||||
<addaction name="actionNew"/>
|
<addaction name="actionNew"/>
|
||||||
<addaction name="actionOpen"/>
|
<addaction name="actionOpen"/>
|
||||||
<addaction name="actionSave"/>
|
<addaction name="actionSave"/>
|
||||||
<addaction name="actionPrint"/>
|
<addaction name="actionPrint"/>
|
||||||
<addaction name="actionExportPDF"/>
|
<addaction name="actionExportPDF"/>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QToolBar" name="toolBar2"/>
|
||||||
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QLabel" name="label">
|
<widget class="QLabel" name="label">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
|
@@ -742,7 +742,7 @@ template void MainWindow::createFor<Room>();
|
|||||||
void MainWindow::showGameInformation()
|
void MainWindow::showGameInformation()
|
||||||
{
|
{
|
||||||
GameInformationDialog dialog{this};
|
GameInformationDialog dialog{this};
|
||||||
if (dialog.exec() == QDialog::Accepted)
|
if (dialog.exec() /*== QDialog::Accepted*/)
|
||||||
changed();
|
changed();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -144,6 +144,7 @@ QMimeData *ActionsContainerModel::mimeData(const QModelIndexList &indexes) const
|
|||||||
|
|
||||||
bool ActionsContainerModel::canDropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) const
|
bool ActionsContainerModel::canDropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) const
|
||||||
{
|
{
|
||||||
|
qDebug() << data->formats();
|
||||||
// if the drop is on an item, reject drop
|
// if the drop is on an item, reject drop
|
||||||
if (parent.isValid() && row == -1 && column == -1)
|
if (parent.isValid() && row == -1 && column == -1)
|
||||||
{
|
{
|
||||||
@@ -156,6 +157,7 @@ bool ActionsContainerModel::canDropMimeData(const QMimeData *data, Qt::DropActio
|
|||||||
|
|
||||||
bool ActionsContainerModel::dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent)
|
bool ActionsContainerModel::dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent)
|
||||||
{
|
{
|
||||||
|
qDebug() << data->formats();
|
||||||
// check if the action is supported
|
// check if the action is supported
|
||||||
if (!data || !(action == Qt::CopyAction || action == Qt::MoveAction))
|
if (!data || !(action == Qt::CopyAction || action == Qt::MoveAction))
|
||||||
{
|
{
|
||||||
|
@@ -33,7 +33,11 @@
|
|||||||
<number>0</number>
|
<number>0</number>
|
||||||
</property>
|
</property>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QLineEditWithMenu" name="lineEdit"/>
|
<widget class="QLineEditWithMenu" name="lineEdit">
|
||||||
|
<property name="readOnly">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QToolButton" name="toolButton">
|
<widget class="QToolButton" name="toolButton">
|
||||||
|
Reference in New Issue
Block a user