Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
jacquetc committed Nov 15, 2022
2 parents 5ad4e60 + 4c9cd6c commit 0ad1c33
Show file tree
Hide file tree
Showing 24 changed files with 732 additions and 264 deletions.
6 changes: 6 additions & 0 deletions NEWS.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
Version: 2.0.1
Date: 2022-11-15
Type: stable
Description:
- "Fix Theme creation dialog"
---
Version: 2.0.0
Date: 2022-11-13
Type: stable
Expand Down
2 changes: 1 addition & 1 deletion cmake/Findhunspell.cmake
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
find_library(HUNSPELL_LIBRARY NAMES ${PKG_HUNSPELL_LIBRARIES} "libhunspell-1.7.a" "libhunspell" "hunspell" "libhunspell-1.7" "hunspell-1.7" "hunspell-1.8" "hunspell/lib/x86_64-linux-gnu"
find_library(HUNSPELL_LIBRARY NAMES ${PKG_HUNSPELL_LIBRARIES} "libhunspell-1.7" "libhunspell-1.7.a" "libhunspell" "hunspell" "libhunspell-1.7" "hunspell-1.7" "hunspell-1.8" "hunspell/lib/x86_64-linux-gnu"
PATHS "/usr/local/lib" ${SYSTEM_LIB_DIRS} "/usr/lib64" "/lib/x86_64-linux-gnu" "/opt/homebrew/Cellar/hunspell/*/"
HINTS ${PKG_HUNSPELL_LIBRARY_DIRS}
)
Expand Down
7 changes: 2 additions & 5 deletions eu.skribisto.skribisto.appdata.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,9 @@
</screenshot>
</screenshots>
<releases>
<release type="stable" version="2.0.0" date="2022-11-13T00:00:00Z">
<release type="stable" version="2.0.1" date="2022-11-15T00:00:00Z">
<description>
<ul>
<li>Switch to QtWidget application for desktop</li>
<li>Deactivate temporarily QML application</li>
</ul>
<p>Fix Theme creation dialog</p>
</description>
</release>
</releases>
Expand Down
7 changes: 0 additions & 7 deletions src/desktopapp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -73,13 +73,6 @@ set_target_properties(SkribistoDesktop PROPERTIES
target_compile_definitions(SkribistoDesktop
PRIVATE $<$<OR:$<CONFIG:Debug>,$<CONFIG:RelWithDebInfo>>:QT_QML_DEBUG>)

# --------------HUNSPELL --------------------
if(${SKR_DEV})
set(EXTERNAL_INSTALL_LOCATION ${CMAKE_SOURCE_DIR}/../build_skribisto_Release/3rdparty)
set(PKG_HUNSPELL_LIBRARY_DIRS ${EXTERNAL_INSTALL_LOCATION}/hunspell/lib)
set(PKG_HUNSPELL_INCLUDE_DIRS ${EXTERNAL_INSTALL_LOCATION}/hunspell/include)
endif(${SKR_DEV})

# ---------------------------------
target_link_libraries(SkribistoDesktop
PRIVATE skribisto-data skribisto-backend skribisto-common skribisto-desktop-common
Expand Down
5 changes: 4 additions & 1 deletion src/desktopapp/newprojectwizard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,10 @@ void NewProjectWizard::accept()

projectCommands->setProjectName(newProjectId, m_projectName);
projectCommands->setAuthor(newProjectId, ui->authorLineEdit->text());
projectCommands->setLanguageCode(newProjectId, ui->languageComboBox->currentData().toString());

if(!ui->languageComboBox->currentData().toString().isEmpty()){
projectCommands->setLanguageCode(newProjectId, ui->languageComboBox->currentData().toString());
}


// template:
Expand Down
8 changes: 8 additions & 0 deletions src/desktopapp/plugins/overviewPage/outlineitemdelegate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,14 @@ void OutlineItemDelegate::setModelData(QWidget *editor, QAbstractItemModel *mode

skrdata->treeHub()->setSecondaryContent(projectId, treeItemId, document->toSkribistoMarkdown());


QString uniqueDocumentReference = QString("%1_%2_%3").arg(QString::number(projectId), QString::number(treeItemId), "secondary");
textBridge->unsubscribeTextDocument(
uniqueDocumentReference,
textEditor->uuid(),
document);


emit editFinished(index);
}

Expand Down
8 changes: 5 additions & 3 deletions src/desktopapp/plugins/overviewPage/overviewview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -250,10 +250,12 @@ QList<Toolbox *> OverviewView::toolboxes()

void OverviewView::initialize()
{
m_overviewProxyModel->setProjectId(this->projectId());
if(this->projectId() > 0){
m_overviewProxyModel->setProjectId(this->projectId());
expandProjectItems();
restoreExpandStates();

expandProjectItems();
restoreExpandStates();
}

// history
emit this->addToHistoryCalled(this, QVariantMap());
Expand Down
16 changes: 12 additions & 4 deletions src/desktopapp/plugins/textPage/textview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,16 @@ TextView::TextView(QWidget *parent) :

connect(this, &TextView::aboutToBeDestroyed, this, [this](){
saveTextState();
if(m_wasModified){
saveContent(true);
}

QString uniqueDocumentReference = QString("%1_%2_%3").arg(this->projectId()).arg(this->treeItemId()).arg(m_isSecondaryContent ? "secondary" : "primary");
textBridge->unsubscribeTextDocument(
uniqueDocumentReference,
centralWidgetUi->textEdit->uuid(),
static_cast<MarkdownTextDocument *>(centralWidgetUi->textEdit->document()));

});


Expand All @@ -94,9 +104,6 @@ TextView::TextView(QWidget *parent) :
TextView::~TextView()
{

if(m_wasModified){
saveContent(true);
}

delete centralWidgetUi;
}
Expand Down Expand Up @@ -184,6 +191,8 @@ void TextView::initialize()

QSettings settings;

// spellchecker :

m_highlighter = new Highlighter(document);
m_highlighter->setProjectId(this->projectId());
m_highlighter->getSpellChecker()->setLangCode(skrdata->projectHub()->getLangCode(this->projectId()));
Expand Down Expand Up @@ -293,7 +302,6 @@ void TextView::connectSaveConnection()
});

}

//---------------------------------------------

void TextView::addPositionToHistory()
Expand Down
4 changes: 2 additions & 2 deletions src/desktopapp/plugins/textPage/textview.ui
Original file line number Diff line number Diff line change
Expand Up @@ -114,13 +114,13 @@
</property>
<property name="minimumSize">
<size>
<width>2</width>
<width>4</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>2</width>
<width>4</width>
<height>16777215</height>
</size>
</property>
Expand Down
1 change: 1 addition & 0 deletions src/desktopapp/settings/appearancesettingspanel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ AppearanceSettingsPanel::AppearanceSettingsPanel(QWidget *parent) :
connect(ui->createThemeButton, &QPushButton::clicked, this, [this](){
ThemeWizard wizard(this);
wizard.exec();
AppearanceSettingsPanel::reset();
});


Expand Down
84 changes: 74 additions & 10 deletions src/desktopapp/themewizard.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#include "themewizard.h"
#include "thememanager.h"
#include "ui_themewizard.h"

#include <QColorDialog>
Expand All @@ -10,13 +9,13 @@ ThemeWizard::ThemeWizard(QWidget *parent) :
{
ui->setupUi(this);


ui->themeTreeWidget->setHeaderLabel(tr("Themes"));

ui->typeComboBox->addItem(tr("Light"), "light");
ui->typeComboBox->addItem(tr("Dark"), "dark");



resetThemeList();
themeManager->scanChildrenAndAddWidgetsHoldingIcons(this);

Expand Down Expand Up @@ -53,12 +52,22 @@ ThemeWizard::ThemeWizard(QWidget *parent) :
QMap<QString, QString> colorMap = themeManager->getColorMap(m_selectedTheme);
this->setColorTableColors(colorMap);

ui->themeExampleWidget->setPalette(themeManager->toPalette(colorMap));
ui->comboBoxExample->setPalette(themeManager->toPalette(colorMap));
QPalette palette = themeManager->toPalette(colorMap);
// side example tab :
QPalette sidePalette = themeManager->createSidePalette(palette);
ui->sideThemeExampleWidget->setPalette(sidePalette);
ui->comboBoxExample->setPalette(sidePalette);
QTimer::singleShot(0, this, [this](){
ui->comboBoxExample->shakePalette();
});

// middle example tab :
QPalette middlePalette = themeManager->createMiddlePalette(palette);
ui->middleThemeExampleWidget->setPalette(middlePalette);
ui->comboBoxExample_2->setPalette(middlePalette);
QTimer::singleShot(0, this, [this](){
ui->comboBoxExample_2->shakePalette();
});
}

});
Expand All @@ -67,16 +76,61 @@ ThemeWizard::ThemeWizard(QWidget *parent) :
QBrush brush = item->background();
QColor newColor = QColorDialog::getColor(brush.color(), this, tr("Select Color"), QColorDialog::ShowAlphaChannel | QColorDialog::DontUseNativeDialog);

item->setBackground(QBrush(QColor(newColor)));
if(newColor.isValid()){
ui->colorTableWidget->item(item->row(), 1)->setBackground(QBrush(QColor(newColor)));

auto colorMap = getColorMapFromTable();
ui->themeExampleWidget->setPalette(themeManager->toPalette(colorMap));
ui->comboBoxExample->setPalette(themeManager->toPalette(colorMap));
auto colorMap = getColorMapFromTable();
ui->sideThemeExampleWidget->setPalette(themeManager->toPalette(colorMap));
ui->comboBoxExample->setPalette(themeManager->toPalette(colorMap));
QTimer::singleShot(0, this, [this](){ ui->comboBoxExample->shakePalette();});

qDebug() << ui->comboBoxExample->palette().button().color().name();
QTimer::singleShot(0, this, [this](){ ui->comboBoxExample->shakePalette();});
}
});

connect(ui->nameLineEdit, &QLineEdit::textChanged, this, [this](const QString &themeName){

bool isEditableAndExists = themeManager->themeWithEditableHash().value(themeName, false);

if(isEditableAndExists){
this->button(QWizard::WizardButton::FinishButton)->setEnabled(true);

if(themeManager->lightThemeWithLocationMap().contains(themeName)){
m_outputFileName = themeManager->lightThemeWithLocationMap().value(themeName);
}
else if(themeManager->darkThemeWithLocationMap().contains(themeName)){
m_outputFileName = themeManager->darkThemeWithLocationMap().value(themeName);
}

ui->outputInfoLabel->setText(tr("Replacing: %1").arg(m_outputFileName));
} //if new name :
else if (!themeManager->themeWithEditableHash().contains(themeName)){

this->button(QWizard::WizardButton::FinishButton)->setEnabled(true);
QString validatorText = themeName;
validatorText.remove("*");
validatorText.remove(QRegularExpression("[<>:\"/\\\\\\|\\?]."));

m_outputFileName = themeManager->getWritablePathForTheme() + "/" + validatorText + ".json";
ui->outputInfoLabel->setText(tr("Creating: %1").arg(m_outputFileName));
}
else{
this->button(QWizard::WizardButton::FinishButton)->setEnabled(false);
ui->outputInfoLabel->setText(tr("Error: The name of this theme already exists!"));
}


});

connect(ui->typeComboBox, &QComboBox::activated, this, [this](int index){
if(index == 0){
m_outputThemeType = ThemeManager::Light;
}
else if(index == 1){
m_outputThemeType = ThemeManager::Dark;
}

});
m_outputThemeType = ThemeManager::Light;
}

ThemeWizard::~ThemeWizard()
Expand Down Expand Up @@ -233,3 +287,13 @@ QMap<QString, QString> ThemeWizard::getColorMapFromTable() const
//----------------------------------------------------
//----------------------------------------------------



void ThemeWizard::done(int result)
{
if(result == QDialog::Accepted){
themeManager->saveTheme(ui->nameLineEdit->text(), m_outputFileName, m_outputThemeType, getColorMapFromTable());
}

QWizard::done(result);
}
7 changes: 7 additions & 0 deletions src/desktopapp/themewizard.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include <QStyledItemDelegate>
#include <QTableWidgetItem>
#include <QWizard>
#include "thememanager.h"

namespace Ui {
class ThemeWizard;
Expand All @@ -27,7 +28,13 @@ private slots:
void setColorTableColors(QMap<QString, QString> colorMap);
QString getHumanReadableName(const QString &colorPropertyName) const;
QMap<QString, QString> getColorMapFromTable() const;
QString m_outputFileName;
ThemeManager::ThemeType m_outputThemeType;


// QDialog interface
public slots:
void done(int result) override;
};


Expand Down
Loading

0 comments on commit 0ad1c33

Please sign in to comment.