Skip to content

Commit

Permalink
fixe bug in the new split feature + add icon
Browse files Browse the repository at this point in the history
  • Loading branch information
Bramas committed Nov 27, 2013
1 parent d69e622 commit 0b8fc37
Show file tree
Hide file tree
Showing 8 changed files with 39 additions and 13 deletions.
Binary file added source/data/img/splitbutton_closetop.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added source/data/img/splitbutton_horizontal.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions source/icons.qrc
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,7 @@
<file>data/img/separatedPdfHover.png</file>
<file>data/img/linkSync.png</file>
<file>data/img/unlinkSync.png</file>
<file>data/img/splitbutton_closetop.png</file>
<file>data/img/splitbutton_horizontal.png</file>
</qresource>
</RCC>
1 change: 0 additions & 1 deletion source/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,6 @@ MainWindow::MainWindow(QWidget *parent) :
connect(this->ui->actionClean,SIGNAL(triggered()), &FileManager::Instance,SLOT(clean()));
connect(this->ui->actionView, SIGNAL(triggered()), &FileManager::Instance,SLOT(jumpToPdfFromSource()));
connect(this->ui->actionSplitEditor, SIGNAL(toggled(bool)), &FileManager::Instance,SLOT(splitEditor(bool)));
connect(this->ui->actionSplitEditor, SIGNAL(toggled(bool)), &ConfigManager::Instance,SLOT(setSplitEditor(bool)));


connect(&FileManager::Instance, SIGNAL(filenameChanged(QString)), this, SLOT(onFilenameChanged(QString)));
Expand Down
15 changes: 10 additions & 5 deletions source/widgetfile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ WidgetFile::WidgetFile(QWidget *parent) :
_widgetTextEdit->setTextCursor(cur);
_widgetTextEdit->getCurrentFile()->setModified(false);

this->splitEditor(ConfigManager::Instance.splitEditor());
this->splitEditor(false);
}

WidgetFile::~WidgetFile()
Expand Down Expand Up @@ -438,19 +438,24 @@ void WidgetFile::setDictionary(QString dico)

void WidgetFile::splitEditor(bool split)
{
qDebug()<<"split "<<split<<" "<<_editorSplitter->height()<<" "<<_editorSplitter->sizes();
if(!_editorSplitter->height() || !_editorSplitter->sizes().at(1))
{
qDebug()<<"split "<<split<<" "<<_editorSplitter->height()<<" "<<_editorSplitter->sizes();
QList<int> sizes;
sizes << (int)split << 1;
_editorSplitter->setCollapsible(0, !split);
_editorSplitter->setSizes(sizes);
qDebug()<<"split "<<split<<" "<<_editorSplitter->height()<<" "<<sizes<<" "<<_editorSplitter->sizes();
if(split)
{
_editorSplitter->setBackgroundColor(ConfigManager::Instance.getTextCharFormats("line-number").foreground().color());
}
else
{
_editorSplitter->setBackgroundColor(QColor(0,0,0,0));
}
return;
}
QList<int> sizes = _editorSplitter->sizes();
if(split == sizes.first())
if(split == (bool)sizes.first())
{
//already split or not split
return;
Expand Down
1 change: 1 addition & 0 deletions source/widgetfile.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ class WidgetFile : public QWidget
WidgetPdfViewer * widgetPdfViewer() { return _widgetPdfViewer; }
SyntaxHighlighter * syntaxHighlighter() { return _syntaxHighlighter; }
MiniSplitter * verticalSplitter() { return _verticalSplitter; }
MiniSplitter * editorSplitter() { return _editorSplitter; }

void open(QString filename);
void reload();
Expand Down
31 changes: 25 additions & 6 deletions source/widgetstatusbar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@ WidgetStatusBar::WidgetStatusBar(QWidget *parent) :

{
_labelSplitEditor = new WidgetStatusBarButton(this);
QImage incorporatedImage(":/data/img/incorporatedPdf.png");
QImage separatedImage(":/data/img/separatedPdf.png");
QImage incorporatedHoverImage(":/data/img/incorporatedPdfHover.png");
QImage separatedHoverImage(":/data/img/separatedPdfHover.png");
if(ConfigManager::Instance.darkTheme())
QImage incorporatedImage(":/data/img/splitbutton_horizontal.png");
QImage separatedImage(":/data/img/splitbutton_closetop.png");
QImage incorporatedHoverImage(":/data/img/splitbutton_horizontal.png");
QImage separatedHoverImage(":/data/img/splitbutton_closetop.png");
if(!ConfigManager::Instance.darkTheme())
{
incorporatedImage.invertPixels();
separatedImage.invertPixels();
Expand Down Expand Up @@ -177,8 +177,14 @@ void WidgetStatusBar::updateButtons()
_labelDictionary->setEnabled(false);
return;
}
//update split button

QList<int> editorSizes = FileManager::Instance.currentWidgetFile()->editorSplitter()->sizes();
_labelSplitEditor->setChecked(editorSizes.first());


// udate Console widget and errorTable widget
QList<int> sizes = FileManager::Instance.currentWidgetFile()->verticalSplitter()->sizes();
QList<int> sizes= FileManager::Instance.currentWidgetFile()->verticalSplitter()->sizes();
if(sizes[2] == 0)
{
_labelErrorTable->setStyleSheet(QString("background-color:transparent"));
Expand Down Expand Up @@ -285,6 +291,19 @@ void WidgetStatusBarButton::enterEvent(QEvent *)
}
}
}
void WidgetStatusBarButton::setChecked(bool checked)
{
if(this->action() && checked != this->action()->isChecked())
{
this->action()->toggle();
return;
}
if(_checked != checked)
{
this->toggleCheckedWithoutTriggeringAction();
}
}

void WidgetStatusBarButton::toggleChecked()
{
_checked = ! _checked;
Expand Down
2 changes: 1 addition & 1 deletion source/widgetstatusbar.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ class WidgetStatusBarButton : public QWidget

public slots:
void toggleChecked();
void setChecked(bool checked) { if(_checked != checked) this->toggleCheckedWithoutTriggeringAction(); }
void setChecked(bool checked);
private slots:
void toggleCheckedWithoutTriggeringAction();

Expand Down

0 comments on commit 0b8fc37

Please sign in to comment.